当前位置: 首页>>代码示例>>Java>>正文


Java MultipartUploadListing.getMultipartUploads方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.model.MultipartUploadListing.getMultipartUploads方法的典型用法代码示例。如果您正苦于以下问题:Java MultipartUploadListing.getMultipartUploads方法的具体用法?Java MultipartUploadListing.getMultipartUploads怎么用?Java MultipartUploadListing.getMultipartUploads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.model.MultipartUploadListing的用法示例。


在下文中一共展示了MultipartUploadListing.getMultipartUploads方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: abortMultipartUploads

import com.amazonaws.services.s3.model.MultipartUploadListing; //导入方法依赖的package包/类
/**
 * <p>
 * Aborts any multipart uploads that were initiated before the specified date.
 * </p>
 * <p>
 * This method is useful for cleaning up any interrupted multipart uploads.
 * <code>TransferManager</code> attempts to abort any failed uploads,
 * but in some cases this may not be possible, such as if network connectivity
 * is completely lost.
 * </p>
 *
 * @param bucketName
 *            The name of the bucket containing the multipart uploads to
 *            abort.
 * @param date
 *            The date indicating which multipart uploads should be aborted.
 */
public void abortMultipartUploads(String bucketName, Date date)
        throws AmazonServiceException, AmazonClientException {
    MultipartUploadListing uploadListing = s3.listMultipartUploads(appendSingleObjectUserAgent(
            new ListMultipartUploadsRequest(bucketName)));
    do {
        for (MultipartUpload upload : uploadListing.getMultipartUploads()) {
            if (upload.getInitiated().compareTo(date) < 0) {
                s3.abortMultipartUpload(appendSingleObjectUserAgent(new AbortMultipartUploadRequest(
                        bucketName, upload.getKey(), upload.getUploadId())));
            }
        }

        ListMultipartUploadsRequest request = new ListMultipartUploadsRequest(bucketName)
            .withUploadIdMarker(uploadListing.getNextUploadIdMarker())
            .withKeyMarker(uploadListing.getNextKeyMarker());
        uploadListing = s3.listMultipartUploads(appendSingleObjectUserAgent(request));
    } while (uploadListing.isTruncated());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:36,代码来源:TransferManager.java

示例2: abortMultipartUploads

import com.amazonaws.services.s3.model.MultipartUploadListing; //导入方法依赖的package包/类
@Override
public int abortMultipartUploads(S3FileTransferRequestParamsDto params, Date thresholdDate)
{
    // Create an Amazon S3 client.
    AmazonS3Client s3Client = getAmazonS3(params);
    int abortedMultipartUploadsCount = 0;

    try
    {
        // List upload markers. Null implies initial list request.
        String uploadIdMarker = null;
        String keyMarker = null;

        boolean truncated;
        do
        {
            // Create the list multipart request, optionally using the last markers.
            ListMultipartUploadsRequest request = new ListMultipartUploadsRequest(params.getS3BucketName());
            request.setUploadIdMarker(uploadIdMarker);
            request.setKeyMarker(keyMarker);

            // Request the multipart upload listing.
            MultipartUploadListing uploadListing = s3Operations.listMultipartUploads(TransferManager.appendSingleObjectUserAgent(request), s3Client);

            for (MultipartUpload upload : uploadListing.getMultipartUploads())
            {
                if (upload.getInitiated().compareTo(thresholdDate) < 0)
                {
                    // Abort the upload.
                    s3Operations.abortMultipartUpload(TransferManager
                        .appendSingleObjectUserAgent(new AbortMultipartUploadRequest(params.getS3BucketName(), upload.getKey(), upload.getUploadId())),
                        s3Client);

                    // Log the information about the aborted multipart upload.
                    LOGGER.info("Aborted S3 multipart upload. s3Key=\"{}\" s3BucketName=\"{}\" s3MultipartUploadInitiatedDate=\"{}\"", upload.getKey(),
                        params.getS3BucketName(), upload.getInitiated());

                    // Increment the counter.
                    abortedMultipartUploadsCount++;
                }
            }

            // Determine whether there are more uploads to list.
            truncated = uploadListing.isTruncated();
            if (truncated)
            {
                // Record the list markers.
                uploadIdMarker = uploadListing.getNextUploadIdMarker();
                keyMarker = uploadListing.getNextKeyMarker();
            }
        }
        while (truncated);
    }
    finally
    {
        // Shutdown the Amazon S3 client instance to release resources.
        s3Client.shutdown();
    }

    return abortedMultipartUploadsCount;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:62,代码来源:S3DaoImpl.java


注:本文中的com.amazonaws.services.s3.model.MultipartUploadListing.getMultipartUploads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。