本文整理汇总了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;
}