本文整理汇总了Java中com.amazonaws.services.s3.transfer.TransferManager.appendMultipartUserAgent方法的典型用法代码示例。如果您正苦于以下问题:Java TransferManager.appendMultipartUserAgent方法的具体用法?Java TransferManager.appendMultipartUserAgent怎么用?Java TransferManager.appendMultipartUserAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.transfer.TransferManager
的用法示例。
在下文中一共展示了TransferManager.appendMultipartUserAgent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextUploadPartRequest
import com.amazonaws.services.s3.transfer.TransferManager; //导入方法依赖的package包/类
public synchronized UploadPartRequest getNextUploadPartRequest() {
long partSize = Math.min(optimalPartSize, remainingBytes);
boolean isLastPart = (remainingBytes - partSize <= 0);
UploadPartRequest req = null;
if (wrappedStream != null) {
req = new UploadPartRequest()
.withBucketName(bucketName)
.withKey(key)
.withUploadId(uploadId)
.withInputStream(new InputSubstream(wrappedStream, 0, partSize, isLastPart))
.withPartNumber(partNumber++)
.withPartSize(partSize);
} else {
req = new UploadPartRequest()
.withBucketName(bucketName)
.withKey(key)
.withUploadId(uploadId)
.withFile(file)
.withFileOffset(offset)
.withPartNumber(partNumber++)
.withPartSize(partSize);
}
req.withRequesterPays(origReq.isRequesterPays());
TransferManager.appendMultipartUserAgent(req);
if (sseCustomerKey != null) req.setSSECustomerKey(sseCustomerKey);
offset += partSize;
remainingBytes -= partSize;
req.setLastPart(isLastPart);
req.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
req.getRequestClientOptions().setReadLimit(origReq.getReadLimit());
return req;
}
示例2: initiateMultipartUpload
import com.amazonaws.services.s3.transfer.TransferManager; //导入方法依赖的package包/类
/**
* Initiates a multipart upload and returns the upload id
* @param isUsingEncryption
*/
private String initiateMultipartUpload(PutObjectRequest origReq, boolean isUsingEncryption) {
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());
}
TransferManager.appendMultipartUserAgent(req);
req.withAccessControlList(origReq.getAccessControlList())
.withRequesterPays(origReq.isRequesterPays())
.withStorageClass(origReq.getStorageClass())
.withRedirectLocation(origReq.getRedirectLocation())
.withSSECustomerKey(origReq.getSSECustomerKey())
.withSSEAwsKeyManagementParams(origReq.getSSEAwsKeyManagementParams())
.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
String uploadId = s3.initiateMultipartUpload(req).getUploadId();
log.debug("Initiated new multipart upload: " + uploadId);
return uploadId;
}