Example usage for com.amazonaws.services.glacier.model CompleteMultipartUploadResult getArchiveId

List of usage examples for com.amazonaws.services.glacier.model CompleteMultipartUploadResult getArchiveId

Introduction

In this page you can find the example usage for com.amazonaws.services.glacier.model CompleteMultipartUploadResult getArchiveId.

Prototype


public String getArchiveId() 

Source Link

Document

The ID of the archive.

Usage

From source file:de.kopis.glacier.commands.UploadMultipartArchiveCommand.java

License:Open Source License

public void upload(final String vaultName, final File uploadFile, final Long partSize) {
    final String hPartSize = HumanReadableSize.parse(partSize);
    final String hTotalSize = HumanReadableSize.parse(uploadFile.length());

    log.info(String.format("Multipart uploading %s (%s) to vault %s with part size %s (%s).",
            uploadFile.getName(), hTotalSize, vaultName, partSize, hPartSize));
    try {/* w w  w  .j a v a2 s. co  m*/
        final String uploadId = this.initiateMultipartUpload(vaultName, partSize, uploadFile.getName());
        final String checksum = this.uploadParts(uploadId, uploadFile, vaultName, partSize);
        final CompleteMultipartUploadResult result = this.completeMultiPartUpload(uploadId, uploadFile,
                vaultName, checksum);

        log.info("Uploaded Archive ID: " + result.getArchiveId());
        log.info("Local Checksum: " + checksum);
        log.info("Remote Checksum: " + result.getChecksum());
        if (checksum.equals(result.getChecksum())) {
            log.info("Checksums are identical, upload succeeded.");
        } else {
            log.error("Checksums are different, upload failed.");
        }

    } catch (final IOException e) {
        log.error(
                "Something went wrong while multipart uploading " + uploadFile + "." + e.getLocalizedMessage(),
                e);
    } catch (AmazonServiceException e) {
        log.error(
                "Something went wrong at Amazon while uploading " + uploadFile + "." + e.getLocalizedMessage(),
                e);
    } catch (NoSuchAlgorithmException e) {
        log.error("No such algorithm found " + e.getLocalizedMessage(), e);
    } catch (AmazonClientException e) {
        log.error("Something went wrong with the Amazon Client." + e.getLocalizedMessage(), e);
    }
}