use of com.qcloud.cos.internal.UploadPartRequestFactory in project cos-java-sdk-v5 by tencentyun.
the class UploadCallable method uploadInParts.
/**
* Uploads the request in multiple chunks, submitting each upload chunk task to the thread pool
* and recording its corresponding Future object, as well as the multipart upload id.
*/
private UploadResult uploadInParts() throws Exception {
boolean isUsingEncryption = cos instanceof COSEncryptionClient;
long optimalPartSize = getOptimalPartSize(isUsingEncryption);
try {
if (multipartUploadId == null) {
multipartUploadId = initiateMultipartUpload(origReq, isUsingEncryption, optimalPartSize);
}
UploadPartRequestFactory requestFactory = new UploadPartRequestFactory(origReq, multipartUploadId, optimalPartSize);
if (TransferManagerUtils.isUploadParallelizable(origReq, isUsingEncryption)) {
captureUploadStateIfPossible();
uploadPartsInParallel(requestFactory, multipartUploadId);
return null;
} else {
return uploadPartsInSeries(requestFactory);
}
} catch (Exception e) {
publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
performAbortMultipartUpload();
throw e;
} finally {
if (origReq.getInputStream() != null) {
try {
origReq.getInputStream().close();
} catch (Exception e) {
log.warn("Unable to cleanly close input stream: " + e.getMessage(), e);
}
}
}
}
Aggregations