Search in sources :

Example 1 with EncryptedInitiateMultipartUploadRequest

use of com.qcloud.cos.model.EncryptedInitiateMultipartUploadRequest in project cos-java-sdk-v5 by tencentyun.

the class COSEncryptionClient method initiateMultipartUpload.

@Override
public InitiateMultipartUploadResult initiateMultipartUpload(InitiateMultipartUploadRequest req) {
    boolean isCreateEncryptionMaterial = true;
    if (req instanceof EncryptedInitiateMultipartUploadRequest) {
        EncryptedInitiateMultipartUploadRequest cryptoReq = (EncryptedInitiateMultipartUploadRequest) req;
        isCreateEncryptionMaterial = cryptoReq.isCreateEncryptionMaterial();
    }
    return isCreateEncryptionMaterial ? crypto.initiateMultipartUploadSecurely(req) : super.initiateMultipartUpload(req);
}
Also used : EncryptedInitiateMultipartUploadRequest(com.qcloud.cos.model.EncryptedInitiateMultipartUploadRequest)

Example 2 with EncryptedInitiateMultipartUploadRequest

use of com.qcloud.cos.model.EncryptedInitiateMultipartUploadRequest 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)2 EncryptedPutObjectRequest (com.qcloud.cos.model.EncryptedPutObjectRequest)1 InitiateMultipartUploadRequest (com.qcloud.cos.model.InitiateMultipartUploadRequest)1