本文整理匯總了Java中com.amazonaws.services.s3.model.ListObjectsRequest.setDelimiter方法的典型用法代碼示例。如果您正苦於以下問題:Java ListObjectsRequest.setDelimiter方法的具體用法?Java ListObjectsRequest.setDelimiter怎麽用?Java ListObjectsRequest.setDelimiter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.s3.model.ListObjectsRequest
的用法示例。
在下文中一共展示了ListObjectsRequest.setDelimiter方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listBucket
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
public List<String> listBucket(String bkt, String prefix, String delimiter) throws IOException {
ListObjectsRequest listRequest = new ListObjectsRequest();
listRequest.setBucketName(bkt);
listRequest.setDelimiter(delimiter);
listRequest.setPrefix(prefix);
ObjectListing listing = s3.listObjects(listRequest);
ArrayList<String> list = new ArrayList<String>();
for (S3ObjectSummary summ : listing.getObjectSummaries()) {
list.add(summ.getKey());
}
return list;
}
示例2: shouldListCommonPrefixes_ContainingFiles
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Test
public void shouldListCommonPrefixes_ContainingFiles() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/05/");
request.setDelimiter("/");
// When
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
// Then
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isNotTruncated();
}
示例3: shouldListCommonPrefixes_ContainingDirectories
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Test
public void shouldListCommonPrefixes_ContainingDirectories() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/");
request.setDelimiter("/");
// When
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
// Then
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isNotTruncated();
}
示例4: listFileData
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Override
public List<FileData> listFileData(String path) {
List<FileData> ret = new ArrayList<FileData>();
try {
String prefix = extraPath + path;
if (!prefix.endsWith("/")) {
prefix = prefix + "/";
}
prefix = StringUtils.removeStart(prefix, "/");
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucketName).withPrefix(prefix);
listObjectsRequest.setDelimiter("/");
ObjectListing objectListing;
do {
objectListing = s3Client.listObjects(listObjectsRequest);
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
String fileName = FilenameUtils.getName(FilenameUtils.normalize(objectSummary.getKey()));
if (StringUtils.isNotBlank(fileName)) {
ret.add(new FileData(path, fileName));
}
}
listObjectsRequest.setMarker(objectListing.getNextMarker());
} while (objectListing.isTruncated());
} catch (AmazonS3Exception e) {
LOG.error("Error Listing Files: " + e, e);
throw new RuntimeException(e);
}
return ret;
}
示例5: getChildren
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Override
public List<RemoteFile> getChildren(String folderName) throws IOException {
if (!folderName.endsWith("/")) {
folderName = folderName + "/";
}
ListObjectsRequest listRequest = new ListObjectsRequest();
listRequest.setBucketName(getBucketName());
listRequest.setDelimiter("/");
listRequest.setPrefix(folderName);
ObjectListing listing = s3.listObjects(listRequest);
ArrayList<RemoteFile> list = new ArrayList<>();
for (S3ObjectSummary summ : listing.getObjectSummaries()) {
String name = summ.getKey();
long size = summ.getSize();
boolean isDirectory = isFolder(name);
RemoteFile file = new RemoteFile(name, isDirectory, size);
list.add(file);
}
return list;
}
示例6: s3ListObjects
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
private ObjectListing s3ListObjects(String pathPrefix, String delimiter) {
ListObjectsRequest listObjectsRequest = new ListObjectsRequest();
listObjectsRequest.setBucketName(currentAccount.getBucket());
listObjectsRequest.setPrefix(pathPrefix);
if (delimiter != null) {
listObjectsRequest.setDelimiter(delimiter);
}
AmazonS3 s3Client = awsService.getS3Client(currentAccount);
return s3Client.listObjects(listObjectsRequest);
}
示例7: shouldListCommonPrefixesInBatches_ContainingFiles
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Test
public void shouldListCommonPrefixesInBatches_ContainingFiles() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/05/");
request.setMaxKeys(1);
request.setDelimiter("/");
// When
ObjectListing amazonListing = amazonS3Client.listObjects(request);
Observable<ObjectListing> listing = client.listObjects(request);
// Then
while (amazonListing.isTruncated()) {
ObjectListing objectListing = listing.toBlocking().single();
assertThat(objectListing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isTruncated();
amazonListing = amazonS3Client.listNextBatchOfObjects(amazonListing);
listing = client.listNextBatchOfObjects(objectListing);
}
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isNotTruncated();
}
示例8: shouldListCommonPrefixesInBatches_ContainingDirectories
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Test
public void shouldListCommonPrefixesInBatches_ContainingDirectories() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/");
request.setMaxKeys(1);
request.setDelimiter("/");
// When
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
// Then
while (amazonListing.isTruncated()) {
ObjectListing objectListing = listing.toBlocking().single();
assertThat(objectListing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isTruncated();
amazonListing = amazonS3Client.listNextBatchOfObjects(amazonListing);
listing = client.listNextBatchOfObjects(objectListing);
}
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isNotTruncated();
}
示例9: listChildren
import com.amazonaws.services.s3.model.ListObjectsRequest; //導入方法依賴的package包/類
@Override
public List<ObjectInfo> listChildren(String path, boolean recurse) throws IOException {
log.debug("List children at {}/{}", bucket, path);
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(this.bucket);
request.setPrefix(path);
if (!recurse) {
request.setDelimiter("/");
if (!path.endsWith("/")) {
request.setPrefix(path + "/");
}
}
List<ObjectInfo> children = Lists.newArrayList();
ObjectListing objectListing = s3Client.listObjects(request);
while (true) {
for (String commonPrefix : objectListing.getCommonPrefixes()) {
children.add(new S3DirInfo(commonPrefix));
}
for (S3ObjectSummary entry : objectListing.getObjectSummaries()) {
children.add(new S3FileInfo(entry));
}
if (!objectListing.isTruncated()) {
break;
}
objectListing = s3Client.listNextBatchOfObjects(objectListing);
}
return children;
}