AmazonS3_ServiceLocator locator = new AmazonS3_ServiceLocator();
AmazonS3SoapBindingStub binding = new AmazonS3SoapBindingStub(new URL(locator.getAmazonS3Address()), locator);
DataHandler dataHandler = new DataHandler(new SourceDataSource(null, MIMETYPE_OCTET_STREAM, new StreamSource(is)));
binding.addAttachment(dataHandler);
PutObjectResult result = binding.putObject(getBucketName(),
key,
metaData ,
length,
null,
storageClass,
access.getAccessKey(),
access.getAccessCalendar(),
access.generateSignature("PutObject"),
null);
long endTime = System.currentTimeMillis();
Log.info(String.format("%6.02f Kb/s\n", (((double)((double)length * (double)Byte.SIZE)) / 1000D) / ((endTime - startTime) / 1000)));
/* compare md5 hashes */
if (md5.equals(result.getETag().replaceAll("\"", "")) == false)
{
throw new Exception("After putting the S3 object [" + key + "], we compared the md5 hash codes. They did not match\n" + "original: [" + md5 + "]\nS3: [" + result.getETag() + "]");
}
}