本文整理匯總了Java中com.amazonaws.services.s3.model.S3Object.setObjectContent方法的典型用法代碼示例。如果您正苦於以下問題:Java S3Object.setObjectContent方法的具體用法?Java S3Object.setObjectContent怎麽用?Java S3Object.setObjectContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.s3.model.S3Object
的用法示例。
在下文中一共展示了S3Object.setObjectContent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getObject
import com.amazonaws.services.s3.model.S3Object; //導入方法依賴的package包/類
@Override
public S3Object getObject(GetObjectRequest getObjectRequest)
throws AmazonClientException, AmazonServiceException {
// in ESBlobStoreContainerTestCase.java, the prefix is empty,
// so the key and blobName are equivalent to each other
String blobName = getObjectRequest.getKey();
if (!blobs.containsKey(blobName)) {
throw new AmazonS3Exception("[" + blobName + "] does not exist.");
}
// the HTTP request attribute is irrelevant for reading
S3ObjectInputStream stream = new S3ObjectInputStream(
blobs.get(blobName), null, false);
S3Object s3Object = new S3Object();
s3Object.setObjectContent(stream);
return s3Object;
}
示例2: putObject
import com.amazonaws.services.s3.model.S3Object; //導入方法依賴的package包/類
@SuppressWarnings("resource")
@Override
public PutObjectResult putObject(PutObjectRequest putObjectRequest) throws AmazonClientException, AmazonServiceException {
putObjectRequests.add(putObjectRequest);
S3Object s3Object = new S3Object();
s3Object.setBucketName(putObjectRequest.getBucketName());
s3Object.setKey(putObjectRequest.getKey());
if (putObjectRequest.getFile() != null) {
try {
s3Object.setObjectContent(new FileInputStream(putObjectRequest.getFile()));
} catch (FileNotFoundException e) {
throw new AmazonServiceException("Cannot store the file object.", e);
}
} else {
s3Object.setObjectContent(putObjectRequest.getInputStream());
}
objects.add(s3Object);
PutObjectResult putObjectResult = new PutObjectResult();
putObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
return putObjectResult;
}
示例3: envVariablesPresent
import com.amazonaws.services.s3.model.S3Object; //導入方法依賴的package包/類
@Test
void envVariablesPresent() {
S3Object s3ObjectMock = mock(S3Object.class);
s3ObjectMock.setObjectContent(new ByteArrayInputStream("1234".getBytes()));
Mockito.when(amazonS3Client.getObject(any(GetObjectRequest.class))).thenReturn(s3ObjectMock);
Mockito.when(environment.getProperty(Constants.BUCKET_NAME_ENV_VARIABLE)).thenReturn("meep");
underTest.getFileByLocationId("meep");
verify(s3ObjectMock, times(1)).getObjectContent();
}
示例4: handle
import com.amazonaws.services.s3.model.S3Object; //導入方法依賴的package包/類
/**
* @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse)
*/
public AmazonWebServiceResponse<S3Object> handle(HttpResponse response) throws Exception {
/*
* TODO: It'd be nice to set the bucket name and key here, but the information isn't easy to
* pull out of the response/request currently.
*/
S3Object object = new S3Object();
AmazonWebServiceResponse<S3Object> awsResponse = parseResponseMetadata(response);
if (response.getHeaders().get(Headers.REDIRECT_LOCATION) != null) {
object.setRedirectLocation(response.getHeaders().get(Headers.REDIRECT_LOCATION));
}
// If the requester is charged when downloading a object from an
// Requester Pays bucket, then this header is set.
if (response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null) {
object.setRequesterCharged(true);
}
if (response.getHeaders().get(Headers.S3_TAGGING_COUNT) != null) {
object.setTaggingCount(Integer.parseInt(response.getHeaders().get(Headers.S3_TAGGING_COUNT)));
}
ObjectMetadata metadata = object.getObjectMetadata();
populateObjectMetadata(response, metadata);
object.setObjectContent(new S3ObjectInputStream(abortableIs(response), response.getHttpRequest()));
awsResponse.setResult(object);
return awsResponse;
}