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


Java ListVersionsRequest.setKeyMarker方法代码示例

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


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

示例1: deleteAngularjsApp

import com.amazonaws.services.s3.model.ListVersionsRequest; //导入方法依赖的package包/类
void deleteAngularjsApp(String websiteBucket, LambdaLogger logger) {
  logger.log("Removing AngularjsApp content from website versioned S3 bucket");

  // We need to delete every version of every key
  ListVersionsRequest listVersionsRequest = new ListVersionsRequest()
      .withBucketName(websiteBucket);
  VersionListing versionListing;

  AmazonS3 client = TransferManagerBuilder.defaultTransferManager().getAmazonS3Client();
  do {
    versionListing = client.listVersions(listVersionsRequest);
    versionListing
        .getVersionSummaries()
        .stream()
        .filter(k -> (k.getKey().startsWith("app")))
        .forEach(
            k -> {
              logger.log("About to delete version: " + k.getVersionId()
                  + " of AngularjsApp page: " + k.getKey());
              DeleteVersionRequest deleteVersionRequest = new DeleteVersionRequest(websiteBucket,
                  k.getKey(), k.getVersionId());
              client.deleteVersion(deleteVersionRequest);
              logger.log("Successfully deleted version: " + k.getVersionId()
                  + " of AngularjsApp page: " + k.getKey());
            });

    listVersionsRequest.setKeyMarker(versionListing.getNextKeyMarker());
  } while (versionListing.isTruncated());
  logger.log("Finished removing AngularjsApp content from website S3 bucket");
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:31,代码来源:AngularjsAppCustomResourceLambda.java

示例2: removeSdkFromS3

import com.amazonaws.services.s3.model.ListVersionsRequest; //导入方法依赖的package包/类
void removeSdkFromS3(LambdaLogger logger) {
  logger.log("About to remove apigateway sdk from website versioned S3 bucket");
  // We need to delete every version of every key
  ListVersionsRequest listVersionsRequest = new ListVersionsRequest()
      .withBucketName(squashWebsiteBucket);
  VersionListing versionListing;
  IS3TransferManager transferManager = getS3TransferManager();
  AmazonS3 client = transferManager.getAmazonS3Client();
  do {
    versionListing = client.listVersions(listVersionsRequest);
    versionListing
        .getVersionSummaries()
        .stream()
        .filter(
            k -> !(k.getKey().startsWith("20") || k.getKey().equals("today.html") || k.getKey()
                .equals("bookings.html")))
        .forEach(
            k -> {
              logger.log("About to delete version: " + k.getVersionId() + " of API SDK: "
                  + k.getKey());
              DeleteVersionRequest deleteVersionRequest = new DeleteVersionRequest(
                  squashWebsiteBucket, k.getKey(), k.getVersionId());
              client.deleteVersion(deleteVersionRequest);
              logger.log("Successfully deleted version: " + k.getVersionId()
                  + " of API SDK key: " + k.getKey());
            });

    listVersionsRequest.setKeyMarker(versionListing.getNextKeyMarker());
  } while (versionListing.isTruncated());

  logger.log("Finished remove apigateway sdk from website S3 bucket");
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:33,代码来源:ApiGatewayCustomResourceLambda.java

示例3: listVersions

import com.amazonaws.services.s3.model.ListVersionsRequest; //导入方法依赖的package包/类
@Override
public List<DeleteObjectsRequest.KeyVersion> listVersions(final S3FileTransferRequestParamsDto params)
{
    Assert.isTrue(!isRootKeyPrefix(params.getS3KeyPrefix()), "Listing of S3 key versions from root directory is not allowed.");

    AmazonS3Client s3Client = getAmazonS3(params);
    List<DeleteObjectsRequest.KeyVersion> keyVersions = new ArrayList<>();

    try
    {
        ListVersionsRequest listVersionsRequest = new ListVersionsRequest().withBucketName(params.getS3BucketName()).withPrefix(params.getS3KeyPrefix());
        VersionListing versionListing;

        do
        {
            versionListing = s3Operations.listVersions(listVersionsRequest, s3Client);

            for (S3VersionSummary versionSummary : versionListing.getVersionSummaries())
            {
                keyVersions.add(new DeleteObjectsRequest.KeyVersion(versionSummary.getKey(), versionSummary.getVersionId()));
            }

            listVersionsRequest.setKeyMarker(versionListing.getNextKeyMarker());
            listVersionsRequest.setVersionIdMarker(versionListing.getNextVersionIdMarker());
        }
        while (versionListing.isTruncated());
    }
    catch (AmazonS3Exception amazonS3Exception)
    {
        if (S3Operations.ERROR_CODE_NO_SUCH_BUCKET.equals(amazonS3Exception.getErrorCode()))
        {
            throw new IllegalArgumentException("The specified bucket '" + params.getS3BucketName() + "' does not exist.", amazonS3Exception);
        }
        throw new IllegalStateException("Error accessing S3", amazonS3Exception);
    }
    catch (AmazonClientException e)
    {
        throw new IllegalStateException(String
            .format("Failed to list keys/key versions with prefix \"%s\" from bucket \"%s\". Reason: %s", params.getS3KeyPrefix(), params.getS3BucketName(),
                e.getMessage()), e);
    }
    finally
    {
        // Shutdown the AmazonS3Client instance to release resources.
        s3Client.shutdown();
    }

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


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