當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。