/**
* Initiates a multipart upload and returns the upload id
*/
private String initiateMultipartUpload(CopyObjectRequest copyObjectRequest) {
InitiateMultipartUploadRequest initiateMultipartUploadRequest = new InitiateMultipartUploadRequest(
copyObjectRequest.getDestinationBucketName(),
copyObjectRequest.getDestinationKey()).withCannedACL(
copyObjectRequest.getCannedAccessControlList());
if (copyObjectRequest.getAccessControlList() != null) {
initiateMultipartUploadRequest
.setAccessControlList(copyObjectRequest
.getAccessControlList());
}
if (copyObjectRequest.getStorageClass() != null) {
initiateMultipartUploadRequest.setStorageClass(StorageClass
.fromValue(copyObjectRequest.getStorageClass()));
}
if (copyObjectRequest.getDestinationSSECustomerKey() != null) {
initiateMultipartUploadRequest.setSSECustomerKey(
copyObjectRequest.getDestinationSSECustomerKey());
}
if (copyObjectRequest.getSSEAwsKeyManagementParams() != null) {
initiateMultipartUploadRequest
.setSSEAwsKeyManagementParams(copyObjectRequest
.getSSEAwsKeyManagementParams());
}
ObjectMetadata newObjectMetadata = copyObjectRequest.getNewObjectMetadata();
if(newObjectMetadata == null){
newObjectMetadata = new ObjectMetadata();
}
if(newObjectMetadata.getContentType() == null){
newObjectMetadata.setContentType(metadata.getContentType());
}
initiateMultipartUploadRequest.setObjectMetadata(newObjectMetadata);
populateMetadataWithEncryptionParams(metadata,newObjectMetadata);
String uploadId = s3.initiateMultipartUpload(
initiateMultipartUploadRequest).getUploadId();