Search in sources :

Example 11 with ObjectListing

use of com.qcloud.cos.model.ObjectListing in project cos-java-sdk-v5 by tencentyun.

the class ListObjectTest method ListObjectStartWithNoMaxKey.

@Test
public void ListObjectStartWithNoMaxKey() {
    if (!judgeUserInfoValid()) {
        return;
    }
    ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket).withDelimiter("/");
    ObjectListing objectListing = cosclient.listObjects(listObjectsRequest);
    assertEquals(1L, objectListing.getCommonPrefixes().size());
    assertEquals(0L, objectListing.getObjectSummaries().size());
}
Also used : ListObjectsRequest(com.qcloud.cos.model.ListObjectsRequest) ObjectListing(com.qcloud.cos.model.ObjectListing) Test(org.junit.Test)

Example 12 with ObjectListing

use of com.qcloud.cos.model.ObjectListing in project alluxio by Alluxio.

the class COSUnderFileSystem method getObjectListingChunk.

@Override
protected ObjectListingChunk getObjectListingChunk(String key, boolean recursive) throws IOException {
    String delimiter = recursive ? "" : PATH_SEPARATOR;
    key = PathUtils.normalizePath(key, PATH_SEPARATOR);
    // In case key is root (empty string) do not normalize prefix
    key = key.equals(PATH_SEPARATOR) ? "" : key;
    ListObjectsRequest request = new ListObjectsRequest();
    request.setBucketName(mBucketNameInternal);
    request.setPrefix(key);
    request.setMaxKeys(getListingChunkLength(mUfsConf));
    request.setDelimiter(delimiter);
    ObjectListing result = getObjectListingChunk(request);
    if (result != null) {
        return new COSObjectListingChunk(request, result);
    }
    return null;
}
Also used : ListObjectsRequest(com.qcloud.cos.model.ListObjectsRequest) ObjectListing(com.qcloud.cos.model.ObjectListing)

Aggregations

ObjectListing (com.qcloud.cos.model.ObjectListing)12 ListObjectsRequest (com.qcloud.cos.model.ListObjectsRequest)9 COSObjectSummary (com.qcloud.cos.model.COSObjectSummary)7 Test (org.junit.Test)6 CosClientException (com.qcloud.cos.exception.CosClientException)3 CosServiceException (com.qcloud.cos.exception.CosServiceException)3 COSClient (com.qcloud.cos.COSClient)2 ClientConfig (com.qcloud.cos.ClientConfig)2 BasicCOSCredentials (com.qcloud.cos.auth.BasicCOSCredentials)2 COSCredentials (com.qcloud.cos.auth.COSCredentials)2 ListNextBatchOfObjectsRequest (com.qcloud.cos.model.ListNextBatchOfObjectsRequest)2 Region (com.qcloud.cos.region.Region)2 ArrayList (java.util.ArrayList)2 COSProgressListener (com.qcloud.cos.event.COSProgressListener)1 COSProgressListenerChain (com.qcloud.cos.event.COSProgressListenerChain)1 MultipleFileTransferProgressUpdatingListener (com.qcloud.cos.event.MultipleFileTransferProgressUpdatingListener)1 MultipleFileTransferStateChangeListener (com.qcloud.cos.event.MultipleFileTransferStateChangeListener)1 ProgressListener (com.qcloud.cos.event.ProgressListener)1 ProgressListenerChain (com.qcloud.cos.event.ProgressListenerChain)1 ResponseNotCompleteException (com.qcloud.cos.exception.ResponseNotCompleteException)1