s3Object.setDataInputFile(uploadFile);
// Compute the upload file's MD5 hash.
InputStream inputStream = new BufferedInputStream(new FileInputStream(uploadFile));
if (progressWatcher != null) {
inputStream = new ProgressMonitoredInputStream(inputStream, progressWatcher);
}
s3Object.setMd5Hash(ServiceUtils.computeMD5Hash(inputStream));
if (!uploadFile.equals(dataFile)) {
// Compute the MD5 hash of the *original* file, if upload file has been altered
// through encryption or gzipping.
inputStream = new BufferedInputStream(new FileInputStream(dataFile));
if (progressWatcher != null) {
inputStream = new ProgressMonitoredInputStream(inputStream, progressWatcher);
}
s3Object.addMetadata(
S3Object.METADATA_HEADER_ORIGINAL_HASH_MD5,
ServiceUtils.toBase64(ServiceUtils.computeMD5Hash(inputStream)));