本文整理汇总了Java中com.amazonaws.services.s3.model.ListObjectsRequest.setPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java ListObjectsRequest.setPrefix方法的具体用法?Java ListObjectsRequest.setPrefix怎么用?Java ListObjectsRequest.setPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.ListObjectsRequest
的用法示例。
在下文中一共展示了ListObjectsRequest.setPrefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareCurrentListing
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
private void prepareCurrentListing() {
while ( currentListing == null || (!currentIterator.hasNext() && currentListing.isTruncated()) ) {
if ( currentListing == null ) {
ListObjectsRequest req = new ListObjectsRequest();
req.setBucketName(getBucketName());
req.setPrefix(getPrefix());
req.setMaxKeys(getBatchSize());
currentListing = getS3().listObjects(req);
} else {
currentListing = getS3().listNextBatchOfObjects(currentListing);
}
currentIterator = currentListing.getObjectSummaries().iterator();
}
}
示例2: getFileNames
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Override
protected List<String> getFileNames(String lockPrefix) throws Exception
{
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucket);
request.setPrefix(lockPrefix);
ObjectListing objectListing = client.listObjects(request);
return Lists.transform
(
objectListing.getObjectSummaries(),
new Function<S3ObjectSummary, String>()
{
@Override
public String apply(S3ObjectSummary summary)
{
return summary.getKey();
}
}
);
}
示例3: getAllChildren
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
public ArrayList<String> getAllChildren(String folderName) throws IOException {
ListObjectsRequest listRequest = new ListObjectsRequest();
listRequest.setBucketName(getBucketName());
listRequest.setPrefix(folderName);
ObjectListing listing = s3.listObjects(listRequest);
ArrayList<String> list = new ArrayList<String>();
System.out.println(listing.getObjectSummaries().size());
for (S3ObjectSummary summ : listing.getObjectSummaries()) {
list.add(summ.getKey());
}
return list;
}
示例4: 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;
}
示例5: shouldListObjectsWhenUsingRequest
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Test
public void shouldListObjectsWhenUsingRequest() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/05/");
// When
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
// Then
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing);
}
示例6: shouldListObjectBatchesWhenStartingWithARequest
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Test
public void shouldListObjectBatchesWhenStartingWithARequest() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/06/");
// When & Then
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
while (amazonListing.isTruncated()) {
assertThat(listing).isEqualTo(amazonListing);
listing = client.listNextBatchOfObjects(listing.toBlocking().single());
amazonListing = amazonS3Client.listNextBatchOfObjects(amazonListing);
}
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing).isNotTruncated();
}
示例7: shouldListObjectWithMaxKeysLimit
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Test
public void shouldListObjectWithMaxKeysLimit() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/");
request.setMaxKeys(2);
// When
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
// Then
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isTruncated()
.hasSize(2);
}
示例8: shouldListObjectBatchesWhenUsingRequest
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Test
public void shouldListObjectBatchesWhenUsingRequest() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setMaxKeys(2);
request.setPrefix("COUNTRY_BY_DATE/2014/");
// When & Then
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
while (amazonListing.isTruncated()) {
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing);
listing = client.listNextBatchOfObjects(listing.toBlocking().single());
amazonListing = amazonS3Client.listNextBatchOfObjects(amazonListing);
}
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isNotTruncated();
}
示例9: shouldReturnEmptyListingWhenNotTruncated
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Test
public void shouldReturnEmptyListingWhenNotTruncated() throws IOException {
// Given
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(bucketName);
request.setPrefix("COUNTRY_BY_DATE/2014/");
Observable<ObjectListing> listing = client.listObjects(request);
ObjectListing amazonListing = amazonS3Client.listObjects(request);
assertThat(listing)
.ignoreFields(fieldsToIgnore)
.isEqualTo(amazonListing)
.isNotTruncated();
// When
listing = client.listNextBatchOfObjects(listing.toBlocking().single());
amazonListing = amazonS3Client.listNextBatchOfObjects(amazonListing);
// Then
assertThat(listing).isEqualTo(amazonListing).isNotNull();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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;
}
示例13: list
import com.amazonaws.services.s3.model.ListObjectsRequest; //导入方法依赖的package包/类
@Override
public void list(String keyPrefix, FileListing callback)
{
checkArgument(keyPrefix != null, "keyPrefix is null");
String errorMessage = "listing files on bucket " + bucket + " prefix " + keyPrefix;
ListObjectsRequest req = new ListObjectsRequest();
req.setBucketName(bucket);
req.setPrefix(keyPrefix);
ObjectListing listing;
do {
try {
listing = getWithRetry(errorMessage, () -> client.listObjects(req));
}
catch (StorageFileNotFoundException ex) {
throw Throwables.propagate(ex.getCause());
}
callback.accept(Lists.transform(
listing.getObjectSummaries(),
(summary) -> StorageObjectSummary.builder()
.key(summary.getKey())
.contentLength(summary.getSize())
.lastModified(summary.getLastModified().toInstant())
.build()
));
req.setMarker(listing.getNextMarker());
}
while (listing.isTruncated());
}
示例14: 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);
}
示例15: 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();
}