amazon glacier sns sqs High Level Archive Retriever - Java AWS

Java examples for AWS:Glacier

Description

amazon glacier sns sqs High Level Archive Retriever

Demo Code


import java.io.File;
import java.io.IOException;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.glacier.AmazonGlacierClient;
import com.amazonaws.services.glacier.transfer.ArchiveTransferManager;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sqs.AmazonSQSClient;

public class HighLevelArchiveRetriever {

    public static String vaultName = "GLACIER_TEST";
    public static String archiveId = "ArchiveId";

    public static void main(String[] args) throws IOException {
        ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost("xx.xx.xx.xx");
        clientConfiguration.setProxyPort(0);

        AWSCredentials credentials = new PropertiesCredentials(
                VaultCreator.class
                        .getResourceAsStream("AwsCredentials.properties"));
        AmazonGlacierClient client = new AmazonGlacierClient(credentials,
                clientConfiguration);//from  www  .j  a  va 2 s.com
        client.setEndpoint("https://glacier.ap-northeast-1.amazonaws.com/");
        try {
            File downloadFile = new File(
                    "/glacier/archive.dat");
            AmazonSQSClient sqs = new AmazonSQSClient(credentials,
                    clientConfiguration);
            sqs.setEndpoint("https://sqs.ap-northeast-1.amazonaws.com");
            AmazonSNSClient sns = new AmazonSNSClient(credentials,
                    clientConfiguration);
            sns.setEndpoint("https://sns.ap-northeast-1.amazonaws.com");

            ArchiveTransferManager archiveTransferManager = new ArchiveTransferManager(
                    client, sqs, sns);
            archiveTransferManager.download(vaultName, archiveId,
                    downloadFile);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials