当前位置: 首页>>代码示例>>Java>>正文


Java ListObjectsRequest.setPrefix方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:17,代码来源:S3Objects.java

示例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();
            }
        }
    );
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:22,代码来源:S3PseudoLock.java

示例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;
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:18,代码来源:AmazonClient.java

示例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;
    }
 
开发者ID:modcs,项目名称:caboclo,代码行数:18,代码来源:AmazonClient.java

示例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);
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:17,代码来源:AsyncS3ClientTest.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:22,代码来源:AsyncS3ClientTest.java

示例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);
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:20,代码来源:AsyncS3ClientTest.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:27,代码来源:AsyncS3ClientTest.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:23,代码来源:AsyncS3ClientTest.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:19,代码来源:AsyncS3ClientTest.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:19,代码来源:AsyncS3ClientTest.java

示例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;
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:28,代码来源:AmazonClient.java

示例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());
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:32,代码来源:S3Storage.java

示例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);
    }
 
开发者ID:githublemming,项目名称:CloudTrailViewer,代码行数:15,代码来源:S3FileHandler.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:32,代码来源:AsyncS3ClientTest.java


注:本文中的com.amazonaws.services.s3.model.ListObjectsRequest.setPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。