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


Java AmazonS3.deleteBucket方法代码示例

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


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

示例1: deleteBucket

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
/**
 * Delete the bucket specified in constructor
 *
 * @throws S3OperationException in case of a client or server error
 */
@PublicAtsApi
public void deleteBucket() throws S3OperationException {

    AmazonS3 s3Client = getClient();
    // TODO: check for direct method
    // remove all Objects before deleting the bucket
    for (S3ObjectInfo element : listBucket("" /* all */, ".*", true)) {
        deleteObject(element.getName());
    }

    s3Client.deleteBucket(bucketName);
    LOG.info("Deleted bucket '" + bucketName + "'");
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:S3Operations.java

示例2: emptyBucket

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
/**
 * Empties the contents of the given bucket and optionally deletes the bucket
 * 
 * @param s3 The S3 client object to use
 * @param bucketName The bucket to empty
 * @param deleteBucket Flag to determine whether to delete the bucket after emptying
 * @param context Lambda context object
 */
public static void emptyBucket(AmazonS3 s3, String bucketName, boolean deleteBucket, Context context)
{
    if (s3.doesBucketExistV2(bucketName))
    {
        logDebug("Emptying bucket '" + bucketName + "'...", context);
        
        VersionListing versionListing = s3.listVersions(new ListVersionsRequest().withBucketName(bucketName));
        while (true) 
        {
            for (S3VersionSummary vs : versionListing.getVersionSummaries()) 
            {
                s3.deleteVersion(bucketName, vs.getKey(), vs.getVersionId());
            }
            
            if (versionListing.isTruncated()) 
            {
                logDebug("Fetching next batch of versions for bucket '" + bucketName + "'", context);
                versionListing = s3.listNextBatchOfVersions(versionListing);
            } 
            else 
            {
                break;
            }
        }
        
        logInfo("Successfully emptied bucket '" + bucketName + "'", context);
        
        if (deleteBucket)
        {
            logDebug("Deleting bucket '" + bucketName + "'...", context);
            s3.deleteBucket(bucketName);
            logInfo("Successfully deleted bucket '" + bucketName + "'", context);
        }
    }
    else
    {
        logWarn("Bucket '" + bucketName + "' does not exist", context);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-lambda-java-utils,代码行数:48,代码来源:S3Cleaner.java


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