Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
*/
package com.amazonaws.services.s3.iterable;

import java.util.Iterator;

import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;

import java.util.Iterator;

/**
* Provides an easy way to iterate Amazon S3 objects in a "foreach" statement.
* For example:
Expand All @@ -39,6 +39,7 @@ public class S3Objects implements Iterable<S3ObjectSummary> {

private AmazonS3 s3;
private String prefix = null;
private String delimiter = null;
private String bucketName;
private Integer batchSize = null;

Expand Down Expand Up @@ -91,6 +92,17 @@ public S3Objects withBatchSize(int batchSize) {
return this;
}

/**
* Sets the delimiter.
*
* @param delimiter
* The delimiter.
*/
public S3Objects withDelimiter(String delimiter) {
this.delimiter = delimiter;
return this;
}

public Integer getBatchSize() {
return batchSize;
}
Expand All @@ -99,6 +111,10 @@ public String getPrefix() {
return prefix;
}

public String getDelimiter() {
return delimiter;
}

public String getBucketName() {
return bucketName;
}
Expand Down Expand Up @@ -137,6 +153,7 @@ private void prepareCurrentListing() {
ListObjectsRequest req = new ListObjectsRequest();
req.setBucketName(getBucketName());
req.setPrefix(getPrefix());
req.setDelimiter(getDelimiter());
req.setMaxKeys(getBatchSize());
currentListing = getS3().listObjects(req);
} else {
Expand Down