本文整理匯總了Java中com.amazonaws.services.s3.model.ObjectListing.setBucketName方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectListing.setBucketName方法的具體用法?Java ObjectListing.setBucketName怎麽用?Java ObjectListing.setBucketName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.s3.model.ObjectListing
的用法示例。
在下文中一共展示了ObjectListing.setBucketName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listNextBatchOfObjects
import com.amazonaws.services.s3.model.ObjectListing; //導入方法依賴的package包/類
@Override
public ObjectListing listNextBatchOfObjects(ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest)
throws SdkClientException, AmazonServiceException {
listNextBatchOfObjectsRequest = beforeClientExecution(listNextBatchOfObjectsRequest);
rejectNull(listNextBatchOfObjectsRequest,
"The request object parameter must be specified when listing the next batch of objects in a bucket");
ObjectListing previousObjectListing = listNextBatchOfObjectsRequest.getPreviousObjectListing();
if (!previousObjectListing.isTruncated()) {
ObjectListing emptyListing = new ObjectListing();
emptyListing.setBucketName(previousObjectListing.getBucketName());
emptyListing.setDelimiter(previousObjectListing.getDelimiter());
emptyListing.setMarker(previousObjectListing.getNextMarker());
emptyListing.setMaxKeys(previousObjectListing.getMaxKeys());
emptyListing.setPrefix(previousObjectListing.getPrefix());
emptyListing.setEncodingType(previousObjectListing.getEncodingType());
emptyListing.setTruncated(false);
return emptyListing;
}
return listObjects(listNextBatchOfObjectsRequest.toListObjectsRequest());
}
示例2: listObjects
import com.amazonaws.services.s3.model.ObjectListing; //導入方法依賴的package包/類
@Override
public ObjectListing listObjects(ListObjectsRequest request) throws AmazonClientException, AmazonServiceException {
int currentRequestCount = requestCount.incrementAndGet();
assertEquals("mycamelbucket", request.getBucketName());
if (currentRequestCount == 2) {
assertEquals("confidential", request.getPrefix());
}
ObjectListing response = new ObjectListing();
response.setBucketName(request.getBucketName());
response.setPrefix(request.getPrefix());
S3ObjectSummary s3ObjectSummary = new S3ObjectSummary();
s3ObjectSummary.setBucketName(request.getBucketName());
s3ObjectSummary.setKey("key");
response.getObjectSummaries().add(s3ObjectSummary);
return response;
}
示例3: listNextBatchOfObjects
import com.amazonaws.services.s3.model.ObjectListing; //導入方法依賴的package包/類
public void listNextBatchOfObjects(ObjectListing objectListing, Subscriber<ObjectListing> observable) {
if (!objectListing.isTruncated()) {
ObjectListing emptyListing = new ObjectListing();
emptyListing.setBucketName(objectListing.getBucketName());
emptyListing.setDelimiter(objectListing.getDelimiter());
emptyListing.setMarker(objectListing.getNextMarker());
emptyListing.setMaxKeys(objectListing.getMaxKeys());
emptyListing.setPrefix(objectListing.getPrefix());
emptyListing.setTruncated(false);
observable.onNext(objectListing);
observable.onCompleted();
}
listObjects(new ListObjectsRequest(
objectListing.getBucketName(),
objectListing.getPrefix(),
objectListing.getNextMarker(),
objectListing.getDelimiter(),
objectListing.getMaxKeys()), observable);
}
示例4: objectListingAnswer
import com.amazonaws.services.s3.model.ObjectListing; //導入方法依賴的package包/類
private Answer<ObjectListing> objectListingAnswer(@Nullable final String marker, final String... fileNames) {
return new Answer<ObjectListing>() {
@Override
public ObjectListing answer(InvocationOnMock invocation)
throws Throwable {
ListObjectsRequest request = (ListObjectsRequest) invocation.getArguments()[0];
ObjectListing objectListing = new ObjectListing();
objectListing.setBucketName(request.getBucketName());
objectListing.setPrefix(request.getPrefix());
objectListing.setTruncated(marker != null);
objectListing.setNextMarker(marker);
for (String fileName : fileNames) {
S3ObjectSummary objectSummary = new S3ObjectSummary();
objectSummary.setKey(request.getPrefix() + fileName);
objectSummary.setSize(100);
objectListing.getObjectSummaries().add(objectSummary);
}
return objectListing;
}
};
}
示例5: listObjects
import com.amazonaws.services.s3.model.ObjectListing; //導入方法依賴的package包/類
/**
* {@inheritDoc}
* <p/>
* If the bucket does not exist, returns a listing with an empty list. If a prefix is specified in listObjectsRequest, only keys starting with the prefix
* will be returned.
*/
@Override
public ObjectListing listObjects(ListObjectsRequest listObjectsRequest, AmazonS3 s3Client)
{
LOGGER.debug("listObjects(): listObjectsRequest.getBucketName() = " + listObjectsRequest.getBucketName());
String bucketName = listObjectsRequest.getBucketName();
if (MOCK_S3_BUCKET_NAME_NO_SUCH_BUCKET_EXCEPTION.equals(bucketName))
{
AmazonS3Exception amazonS3Exception = new AmazonS3Exception(MOCK_S3_BUCKET_NAME_NO_SUCH_BUCKET_EXCEPTION);
amazonS3Exception.setErrorCode("NoSuchBucket");
throw amazonS3Exception;
}
ObjectListing objectListing = new ObjectListing();
objectListing.setBucketName(bucketName);
MockS3Bucket mockS3Bucket = mockS3Buckets.get(bucketName);
if (mockS3Bucket != null)
{
for (MockS3Object mockS3Object : mockS3Bucket.getObjects().values())
{
String s3ObjectKey = mockS3Object.getKey();
if (listObjectsRequest.getPrefix() == null || s3ObjectKey.startsWith(listObjectsRequest.getPrefix()))
{
S3ObjectSummary s3ObjectSummary = new S3ObjectSummary();
s3ObjectSummary.setBucketName(bucketName);
s3ObjectSummary.setKey(s3ObjectKey);
s3ObjectSummary.setSize(mockS3Object.getData().length);
s3ObjectSummary.setStorageClass(mockS3Object.getObjectMetadata() != null ? mockS3Object.getObjectMetadata().getStorageClass() : null);
objectListing.getObjectSummaries().add(s3ObjectSummary);
}
}
}
return objectListing;
}