I've managed to upload a file to Glacier, but I want to upload to Deep Archive directly. I've searched the documentation, but found no mentions of how to set the storage class to DEEP_ARCHIVE
directly.
To upload data, such as photos, videos, and other documents, you must either use the AWS CLI or write code to make requests, by using either the REST API directly or by using the Amazon SDKs. For information about using S3 Glacier with the AWS CLI, go to AWS CLI Reference for S3 Glacier.
The easiest way to store data in S3 Glacier Deep Archive is to use the S3 PUT API to upload data directly. You can also upload data to S3 Glacier Deep Archive over the internet or using AWS Direct Connect and the AWS Management Console, AWS Storage Gateway, AWS Command Line Interface, or the AWS SDKs.
Store the data in 2 "folders" in S3, "standard" and "glacier". Set a lifecycle policy to push all objects in the "glacier" folder to Glacier data storage ASAP. When you want to move an object from standard to glacier, copy it to the glacier folder and delete the object in the standard folder (there's no "move" API).
Currently, there is no way of uploading objects directly to S3 Glacier using a Snowball Edge. Thus, you first have to upload your objects into S3 Standard, and then use S3 lifecycle policies to transition the files to S3 Glacier.
You can either use put_object()
, which has a StorageClass
parameter, or you can use upload_file()
while specifying ExtraArgs
:
import boto3
s3_client = boto3.client('s3')
s3_client.upload_file('/tmp/hello.txt', 'my-bucket', 'hello.txt', ExtraArgs={'StorageClass': 'DEEP_ARCHIVE'})
Permitted ExtraArgs
can be found at ALLOWED_UPLOAD_ARGS.
To clarify: This is uploading to Amazon S3 but setting the Storage Class to Glacier Deep Archive. This is different to uploading to the Amazon Glacier service. (These days it is easier to use Glacier via S3 storage classes).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With