This page is only for existing customers of the Amazon Glacier service using Vaults and the original REST API from 2012.
If you're looking for archival storage solutions, we recommend using the Amazon Glacier storage classes in Amazon S3, S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive. To learn more about these storage options, see Amazon Glacier storage classes
Amazon Glacier (original standalone vault-based service) will no longer accept new customers starting December 15, 2025, with no impact to existing customers. Amazon Glacier is a standalone service with its own APIs that stores data in vaults and is distinct from Amazon S3 and the Amazon S3 Glacier storage classes. Your existing data will remain secure and accessible in Amazon Glacier indefinitely. No migration is required. For low-cost, long-term archival storage, Amazon recommends the Amazon S3 Glacier storage classes
Using the Amazon SDK for Java with Amazon Glacier
The Amazon SDK for Java provides both high-level and low-level APIs for Amazon Glacier (Amazon Glacier) as described in
Using the Amazon SDKs with Amazon Glacier. For information about
downloading the Amazon SDK for Java, see Amazon SDK for
Java
Note
The Amazon SDK for Java provides thread-safe clients for accessing Amazon Glacier. As a best practice, your applications should create one client and reuse the client between threads.
Topics
Using the Low-Level API
The low-level AmazonGlacierClient class provides all the methods that
map to the underlying REST operations of Amazon Glacier ( API Reference for Amazon Glacier). When calling any
of these methods, you must create a corresponding request object and provide a response
object in which the method can return the Amazon Glacier response to the operation.
For example, the AmazonGlacierClient class provides the
createVault method to create a vault. This method maps to the
underlying Create Vault REST operation (see Create Vault (PUT vault)). To use this method, you must create instances of
the CreateVaultResult object that receives the Amazon Glacier response as shown in
the following Java code snippet:
AmazonGlacierClient client = new AmazonGlacierClient(credentials); client.setEndpoint("https://glacier.us-west-2.amazonaws.com.cn/"); CreateVaultRequest request = new CreateVaultRequest() .withAccountId("-") .withVaultName(vaultName); CreateVaultResult result = client.createVault(createVaultRequest);
All the low-level samples in the guide use this pattern.
Note
The preceding code segment specifies AccountID when creating
the request. However, when using the Amazon SDK for Java, the
AccountId in the request is optional, and therefore all the
low-level examples in this guide don't set this value. The
AccountId is the Amazon Web Services account ID. This value must match the Amazon Web Services account ID associated with the credentials used to sign the request. You can
specify either the Amazon Web Services account ID or optionally a '-', in which case Amazon Glacier
uses the Amazon Web Services account ID associated with the credentials used to sign the
request. If you specify your Account ID, do not include hyphens in it. When
using Amazon SDK for Java, if you don't provide the account ID, the library sets
the account ID to '-'.
Using the High-Level API
To further simplify your application development, the Amazon SDK for Java provides
the ArchiveTransferManager class that implements a higher-level abstraction
for the some of the methods in the low-level API. It provides useful methods, such as
the upload and download methods for archive operations.
For example, the following Java code snippet uses the upload
high-level method to upload an archive.
String vaultName = "examplevault"; String archiveToUpload = "c:/folder/exampleArchive.zip"; ArchiveTransferManager atm = new ArchiveTransferManager(client, credentials); String archiveId = atm.upload(vaultName, "Tax 2012 documents", new File(archiveToUpload)).getArchiveId();
Note that any operations you perform apply to the Amazon Region you specified when
creating the ArchiveTransferManager object. If you don't specify any
Amazon Region, the Amazon SDK for Java sets us-east-1 as the
default Amazon Region.
All the high-level examples in this guide use this pattern.
Note
The high-level ArchiveTransferManager class can be
constructed with an AmazonGlacierClient instance or an
AWSCredentials instance.
Running Java Examples for Amazon Glacier Using Eclipse
The easiest way to get started with the Java code examples is to install the
latest Amazon Toolkit for Eclipse. For information on installing or updating to the latest toolkit, go to
http://www.amazonaws.cn/eclipse
1 |
Create a default credentials profile for your Amazon credentials as described in the Amazon SDK for Java topic Providing Amazon Credentials in the Amazon SDK for Java. |
2 |
Create a new Amazon Java project in Eclipse. The project is pre-configured with the Amazon SDK for Java. |
3 |
Copy the code from the section you are reading to your project. |
4 |
Update the code by providing any required data. For example, if uploading a file, provide the file path and the bucket name. |
5 |
Run the code. Verify that the object is created by using the Amazon Web Services Management Console. For more
information about the Amazon Web Services Management Console, go to http://www.amazonaws.cn/console/ |
Setting the Endpoint
By default, the Amazon SDK for Java uses the endpoint
https://glacier.us-east-1.amazonaws.com.cn. You can set the endpoint
explicitly as shown in the following Java code snippets.
The following snippet shows how to set the endpoint to the US West (Oregon) Region
(us-west-2) in the low-level API.
client = new AmazonGlacierClient(credentials); client.setEndpoint("glacier.us-west-2.amazonaws.com.cn");
The following snippet shows how to set the endpoint to the US West (Oregon) Region in the high-level API.
glacierClient = new AmazonGlacierClient(credentials); sqsClient = new AmazonSQSClient(credentials); snsClient = new AmazonSNSClient(credentials); glacierClient.setEndpoint("glacier.us-west-2.amazonaws.com.cn"); sqsClient.setEndpoint("sqs.us-west-2.amazonaws.com.cn"); snsClient.setEndpoint("sns.us-west-2.amazonaws.com.cn"); ArchiveTransferManager atm = new ArchiveTransferManager(glacierClient, sqsClient, snsClient);
For a list of supported Amazon Regions and endpoints, see Accessing Amazon Glacier.