}
Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
Constants.SOAP_SERVICE_NAME + "PutObject" + convertDateToString(timestamp));
PutObjectResult result =
s3SoapBinding.putObject(bucketName, object.getKey(), metadata,
contentLength, grants, null, getAWSAccessKey(),
timestamp, signature, null);
// Ensure no data was corrupted, if we have the MD5 hash available to check.
String eTag = result.getETag().substring(1, result.getETag().length() - 1);
String eTagAsBase64 = ServiceUtils.toBase64(
ServiceUtils.fromHex(eTag));
String md5HashAsBase64 = object.getMd5HashAsBase64();
if (md5HashAsBase64 != null && !eTagAsBase64.equals(md5HashAsBase64)) {
throw new S3ServiceException(
"Object created but ETag returned by S3 does not match MD5 hash value of object");
}
object.setETag(result.getETag());
object.setContentLength(contentLength);
object.setContentType(contentType);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {