當前位置: 首頁>>代碼示例>>Java>>正文


Java TransferManager.appendMultipartUserAgent方法代碼示例

本文整理匯總了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;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:40,代碼來源:UploadPartRequestFactory.java

示例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;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:37,代碼來源:UploadCallable.java


注:本文中的com.amazonaws.services.s3.transfer.TransferManager.appendMultipartUserAgent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。