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


Java S3Object.getObjectMetadata方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.model.S3Object.getObjectMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java S3Object.getObjectMetadata方法的具体用法?Java S3Object.getObjectMetadata怎么用?Java S3Object.getObjectMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.model.S3Object的用法示例。


在下文中一共展示了S3Object.getObjectMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMetaData

import com.amazonaws.services.s3.model.S3Object; //导入方法依赖的package包/类
public ExternalResourceMetaData getMetaData(URI location, boolean revalidate) {
    LOGGER.debug("Attempting to get resource metadata: {}", location);
    S3Object s3Object = s3Client.getMetaData(location);
    if (s3Object == null) {
        return null;
    }
    try {
        ObjectMetadata objectMetadata = s3Object.getObjectMetadata();
        return new DefaultExternalResourceMetaData(location,
            objectMetadata.getLastModified().getTime(),
            objectMetadata.getContentLength(),
            objectMetadata.getContentType(),
            objectMetadata.getETag(),
            null); // Passing null for sha1 - TODO - consider using the etag which is an MD5 hash of the file (when less than 5Gb)
    } finally {
        IoActions.closeQuietly(s3Object);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:S3ResourceConnector.java

示例2: getObject

import com.amazonaws.services.s3.model.S3Object; //导入方法依赖的package包/类
@Override
public ObjectMetadata getObject(final GetObjectRequest getObjectRequest, File destinationFile)
        throws SdkClientException, AmazonServiceException {
    rejectNull(destinationFile,
            "The destination file parameter must be specified when downloading an object directly to a file");

    S3Object s3Object = ServiceUtils.retryableDownloadS3ObjectToFile(destinationFile, new ServiceUtils.RetryableS3DownloadTask() {

        @Override
        public S3Object getS3ObjectStream() {
            return getObject(getObjectRequest);
        }

        @Override
        public boolean needIntegrityCheck() {
            return !skipMd5CheckStrategy.skipClientSideValidationPerRequest(getObjectRequest);
        }

    }, ServiceUtils.OVERWRITE_MODE);
    // getObject can return null if constraints were specified but not met
    if (s3Object == null) return null;

    return s3Object.getObjectMetadata();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:25,代码来源:AmazonS3Client.java

示例3: storeObjectTest

import com.amazonaws.services.s3.model.S3Object; //导入方法依赖的package包/类
@Test
public void storeObjectTest() throws Exception {
    S3Object object = s3Client.getObject(DUMMY_BUCKET_NAME, "pref1/dummy1");

    ObjectMetadata objectMetadata = object.getObjectMetadata();
    BufferedReader reader = new BufferedReader(new InputStreamReader(object.getObjectContent()));
    String storedContent = reader.readLine();
    reader.close();

    assertEquals(objectMetadata.getContentType(), Commons.TEXT_TYPE);
    assertEquals(objectMetadata.getContentLength(), KEY_CONTENT_MAPPING.get("pref1/dummy1").getBytes().length);
    assertEquals(storedContent, KEY_CONTENT_MAPPING.get("pref1/dummy1"));
}
 
开发者ID:d2si-oss,项目名称:ooso,代码行数:14,代码来源:CommonUtilitiesTest.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.getObjectMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。