Example usage for com.amazonaws.services.s3.model ListObjectsV2Request withBucketName

List of usage examples for com.amazonaws.services.s3.model ListObjectsV2Request withBucketName

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model ListObjectsV2Request withBucketName.

Prototype

public ListObjectsV2Request withBucketName(String bucketName) 

Source Link

Document

Sets the name of the Amazon S3 bucket whose objects are to be listed.

Usage

From source file:org.exem.flamingo.web.filesystem.s3.S3BrowserServiceImpl.java

License:Apache License

@Override
public void deleteBucket(String bucketName) {
    ListObjectsV2Request request = new ListObjectsV2Request();
    request.withBucketName(bucketName);
    ListObjectsV2Result result;/*w  ww  . j ava  2  s  .co m*/

    while (true) {
        result = this.s3.listObjectsV2(request);
        for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
            this.s3.deleteObject(bucketName, objectSummary.getKey());
        }
        if (result.isTruncated()) {
            request.setContinuationToken(result.getNextContinuationToken());
        } else {
            break;
        }
    }

    this.s3.deleteBucket(bucketName);
}

From source file:org.exem.flamingo.web.filesystem.s3.S3BrowserServiceImpl.java

License:Apache License

@Override
public void deleteFolder(String bucketName, String key) {
    ListObjectsV2Request request = new ListObjectsV2Request();
    request.withBucketName(bucketName).withPrefix(key).withDelimiter(S3Constansts.DELIMITER);

    ListObjectsV2Result result;//  w w w  .  j a v a2  s  .c  o m

    while (true) {
        result = this.s3.listObjectsV2(request);
        for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
            this.s3.deleteObject(bucketName, objectSummary.getKey());
        }
        if (result.isTruncated()) {
            request.setContinuationToken(result.getNextContinuationToken());
        } else {
            break;
        }
    }
}

From source file:org.exem.flamingo.web.filesystem.s3.S3BrowserServiceImpl.java

License:Apache License

@Override
public ListObjectsV2Result listObjects(String bucketName, String prefix, String continuationToken) {
    ListObjectsV2Request request = new ListObjectsV2Request();
    request.withBucketName(bucketName).withPrefix(prefix).withDelimiter(S3Constansts.DELIMITER);

    if (StringUtils.isNotEmpty(continuationToken)) {
        request.withContinuationToken(continuationToken);
    }/*w  ww .j a  va  2s.  c  om*/

    return this.s3.listObjectsV2(request);
}