Search in sources :

Example 1 with EncryptedPutObjectRequest

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;
}
Also used : EncryptedPutObjectRequest(com.qcloud.cos.model.EncryptedPutObjectRequest) InitiateMultipartUploadRequest(com.qcloud.cos.model.InitiateMultipartUploadRequest) EncryptedInitiateMultipartUploadRequest(com.qcloud.cos.model.EncryptedInitiateMultipartUploadRequest) EncryptedInitiateMultipartUploadRequest(com.qcloud.cos.model.EncryptedInitiateMultipartUploadRequest)

Aggregations

EncryptedInitiateMultipartUploadRequest (com.qcloud.cos.model.EncryptedInitiateMultipartUploadRequest)1 EncryptedPutObjectRequest (com.qcloud.cos.model.EncryptedPutObjectRequest)1 InitiateMultipartUploadRequest (com.qcloud.cos.model.InitiateMultipartUploadRequest)1