use of com.qcloud.cos.model.EncryptedPutObjectRequest in project cos-java-sdk-v5 by tencentyun.
the class UploadCallable method initiateMultipartUpload.
/**
* Initiates a multipart upload and returns the upload id
*
* @param isUsingEncryption
*/
private String initiateMultipartUpload(PutObjectRequest origReq, boolean isUsingEncryption, long optimalPartSize) {
InitiateMultipartUploadRequest req = null;
if (isUsingEncryption && origReq instanceof EncryptedPutObjectRequest) {
req = new EncryptedInitiateMultipartUploadRequest(origReq.getBucketName(), origReq.getKey()).withCannedACL(origReq.getCannedAcl()).withObjectMetadata(origReq.getMetadata());
((EncryptedInitiateMultipartUploadRequest) req).setMaterialsDescription(((EncryptedPutObjectRequest) origReq).getMaterialsDescription());
} else {
req = new InitiateMultipartUploadRequest(origReq.getBucketName(), origReq.getKey()).withCannedACL(origReq.getCannedAcl()).withObjectMetadata(origReq.getMetadata());
}
long dataSize = TransferManagerUtils.getContentLength(origReq);
req.setDataSizePartSize(dataSize, optimalPartSize);
TransferManager.appendMultipartUserAgent(req);
req.withAccessControlList(origReq.getAccessControlList()).withStorageClass(origReq.getStorageClass()).withRedirectLocation(origReq.getRedirectLocation()).withSSECustomerKey(origReq.getSSECustomerKey()).withSSECOSKeyManagementParams(origReq.getSSECOSKeyManagementParams()).withGeneralProgressListener(origReq.getGeneralProgressListener());
TransferManagerUtils.populateEndpointAddr(origReq, req);
String uploadId = cos.initiateMultipartUpload(req).getUploadId();
log.debug("Initiated new multipart upload: " + uploadId);
return uploadId;
}
Aggregations