Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put("test-md-value", "testing, testing, 123");
metadata.put("test-timestamp-value", System.currentTimeMillis());
// Start a multipart upload
MultipartUpload testMultipartUpload = service.multipartStartUpload(
bucketName, objectKey, metadata,
AccessControlList.REST_CANNED_AUTHENTICATED_READ, null);
assertEquals(bucketName, testMultipartUpload.getBucketName());
assertEquals(objectKey, testMultipartUpload.getObjectKey());
// List all ongoing multipart uploads
List<MultipartUpload> uploads = service.multipartListUploads(bucketName);
assertTrue("Expected at least one ongoing upload", uploads.size() >= 1);
// Confirm our newly-created multipart upload is present in listing
boolean foundNewUpload = false;
for (MultipartUpload upload: uploads) {
if (upload.getUploadId().equals(testMultipartUpload.getUploadId())) {
foundNewUpload = true;
}
}
assertTrue("Expected to find the new upload in listing", foundNewUpload);
// Start a second, encrypted multipart upload
S3Object encryptedMultiPartObject = new S3Object(objectKey + "2");
encryptedMultiPartObject.setServerSideEncryptionAlgorithm(
S3Object.SERVER_SIDE_ENCRYPTION__AES256);
MultipartUpload testMultipartUpload2 =
service.multipartStartUpload(bucketName, encryptedMultiPartObject);
assertEquals("AES256",
testMultipartUpload2.getMetadata().get("x-amz-server-side-encryption"));
// List multipart uploads with markers -- Find second upload only
uploads = service.multipartListUploads(bucketName,
"multipart-object.txt",
testMultipartUpload.getUploadId(),
10);
assertEquals(1, uploads.size());
assertEquals(objectKey + "2", uploads.get(0).getObjectKey());
// List multipart uploads with prefix/delimiter constraints
MultipartUpload testMultipartUpload3 =
service.multipartStartUpload(bucketName, objectKey + "/delimited", metadata);
MultipartUploadChunk chunk = service.multipartListUploadsChunked(bucketName,
"multipart-object", // prefix
null, // delimiter