String checksum = TreeHashGenerator.calculateTreeHash(file);
InputStream is = new RepeatableFileInputStream(file);
publishProgress(progressListener, ProgressEventType.TRANSFER_STARTED_EVENT);
try {
UploadArchiveResult uploadArchiveResult =
glacier.uploadArchive(new UploadArchiveRequest()
.withAccountId(accountId)
.withArchiveDescription(archiveDescription)
.withVaultName(vaultName)
.withChecksum(checksum)
.withBody(is)
.withContentLength(file.length())
);
String artifactId = uploadArchiveResult.getArchiveId();
publishProgress(progressListener, ProgressEventType.TRANSFER_COMPLETED_EVENT);
return new UploadResult(artifactId);
} catch (AmazonClientException ace) {
publishProgress(progressListener, ProgressEventType.TRANSFER_FAILED_EVENT);
throw ace;