本文整理汇总了Java中com.amazonaws.services.s3.model.VersionListing.isTruncated方法的典型用法代码示例。如果您正苦于以下问题:Java VersionListing.isTruncated方法的具体用法?Java VersionListing.isTruncated怎么用?Java VersionListing.isTruncated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.VersionListing
的用法示例。
在下文中一共展示了VersionListing.isTruncated方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listNextBatchOfVersions
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的package包/类
@Override
public VersionListing listNextBatchOfVersions(ListNextBatchOfVersionsRequest listNextBatchOfVersionsRequest) {
listNextBatchOfVersionsRequest = beforeClientExecution(listNextBatchOfVersionsRequest);
rejectNull(listNextBatchOfVersionsRequest,
"The request object parameter must be specified when listing the next batch of versions in a bucket");
VersionListing previousVersionListing = listNextBatchOfVersionsRequest.getPreviousVersionListing();
if (!previousVersionListing.isTruncated()) {
VersionListing emptyListing = new VersionListing();
emptyListing.setBucketName(previousVersionListing.getBucketName());
emptyListing.setDelimiter(previousVersionListing.getDelimiter());
emptyListing.setKeyMarker(previousVersionListing.getNextKeyMarker());
emptyListing.setVersionIdMarker(previousVersionListing.getNextVersionIdMarker());
emptyListing.setMaxKeys(previousVersionListing.getMaxKeys());
emptyListing.setPrefix(previousVersionListing.getPrefix());
emptyListing.setEncodingType(previousVersionListing.getEncodingType());
emptyListing.setTruncated(false);
return emptyListing;
}
return listVersions(listNextBatchOfVersionsRequest.toListVersionsRequest());
}
示例2: emptyBucket
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的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);
}
}
示例3: deleteAngularjsApp
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的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");
}
示例4: removeSdkFromS3
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的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");
}
示例5: deleteAllVersions
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的package包/类
private void deleteAllVersions(String bucketName) {
logger.info("Deleting all object versions from bucket '{}'", bucketName);
VersionListing versionListing = s3.listVersions(bucketName, null);
delete(versionListing);
while (versionListing.isTruncated()) {
versionListing = s3.listNextBatchOfVersions(versionListing);
delete(versionListing);
}
}
示例6: main
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的package包/类
public static void main(String[] args)
{
final String USAGE = "\n" +
"To run this example, supply the name of an S3 bucket\n" +
"\n" +
"Ex: DeleteBucket <bucketname>\n";
if (args.length < 1) {
System.out.println(USAGE);
System.exit(1);
}
String bucket_name = args[0];
System.out.println("Deleting S3 bucket: " + bucket_name);
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
try {
System.out.println(" - removing objects from bucket");
ObjectListing object_listing = s3.listObjects(bucket_name);
while (true) {
for (Iterator<?> iterator =
object_listing.getObjectSummaries().iterator();
iterator.hasNext();) {
S3ObjectSummary summary = (S3ObjectSummary)iterator.next();
s3.deleteObject(bucket_name, summary.getKey());
}
// more object_listing to retrieve?
if (object_listing.isTruncated()) {
object_listing = s3.listNextBatchOfObjects(object_listing);
} else {
break;
}
};
System.out.println(" - removing versions from bucket");
VersionListing version_listing = s3.listVersions(
new ListVersionsRequest().withBucketName(bucket_name));
while (true) {
for (Iterator<?> iterator =
version_listing.getVersionSummaries().iterator();
iterator.hasNext();) {
S3VersionSummary vs = (S3VersionSummary)iterator.next();
s3.deleteVersion(
bucket_name, vs.getKey(), vs.getVersionId());
}
if (version_listing.isTruncated()) {
version_listing = s3.listNextBatchOfVersions(
version_listing);
} else {
break;
}
}
System.out.println(" OK, bucket ready to delete!");
s3.deleteBucket(bucket_name);
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.exit(1);
}
System.out.println("Done!");
}
示例7: listVersions
import com.amazonaws.services.s3.model.VersionListing; //导入方法依赖的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;
}