当前位置: 首页>>代码示例>>Java>>正文


Java S3Object.setObjectContent方法代码示例

本文整理汇总了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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:MockAmazonS3.java

示例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;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:24,代码来源:AmazonS3ClientMock.java

示例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();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:11,代码来源:StorageServiceImplTest.java

示例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;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:32,代码来源:S3ObjectResponseHandler.java


注:本文中的com.amazonaws.services.s3.model.S3Object.setObjectContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。