當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。