Example usage for com.amazonaws.services.s3.model ListObjectsRequest ListObjectsRequest

List of usage examples for com.amazonaws.services.s3.model ListObjectsRequest ListObjectsRequest

Introduction

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

Prototype

public ListObjectsRequest(String bucketName, String prefix, String marker, String delimiter, Integer maxKeys) 

Source Link

Document

Constructs a new ListObjectsRequest object and initializes all required and optional object fields.

Usage

From source file:org.onebusaway.admin.service.impl.S3FileServiceImpl.java

License:Apache License

@Override
/**/* w ww. j  a v  a2s .c  om*/
 * list the files in the given directory.
 */
public List<String> list(String directory, int maxResults) {
    ListObjectsRequest request = new ListObjectsRequest(_bucketName, directory, null, null, maxResults);
    ObjectListing listing = _s3.listObjects(request);
    List<String> rows = new ArrayList<String>();
    for (S3ObjectSummary summary : listing.getObjectSummaries()) {
        // if its a directory at the root level
        if (!summary.getKey().endsWith("/")) {
            rows.add(summary.getKey());
        }
    }
    return rows;
}