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


Java AmazonS3.getObjectMetadata方法代码示例

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


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

示例1: run

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
@Override
public void run() {
    super.run();

    String awsCredentialsProfile = this.readStringArgument("awsProfile", "default");
    String bucket = this.readStringArgument("bucket");
    String objectKey = this.readStringArgument("objectKey");

    AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider(awsCredentialsProfile));
    ObjectMetadata metadata = s3Client.getObjectMetadata(
            new GetObjectMetadataRequest(bucket, objectKey));

    try {
        Date expirationTime = metadata.getExpirationTime();
        if (expirationTime != null) {
            this.writeOutput("expirationTime", metadata.getExpirationTime().getTime());
        } else {
            this.writeOutput("expirationTime", null);
        }
        this.writeOutput("lastModified", metadata.getLastModified().getTime());
        this.writeOutput("userMetadata", metadata.getUserMetadata());
        this.writeOutput("size", metadata.getContentLength());
        this.writeOutput("storageClass", metadata.getStorageClass());
        this.writeOutput("versionId", metadata.getVersionId());
    } catch (Exception ex) {
        throw new RuntimeException(String.format(
                "Failed to get object metadata for object key %s in bucket %s",
                objectKey,
                bucket), ex);
    }
}
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:32,代码来源:GetS3Metadata.java

示例2: itDoesntCount404AsFailure

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
@Test
public void itDoesntCount404AsFailure() throws InterruptedException {
  AmazonS3 s3 = HystrixS3Decorator.decorate(new MissingS3Client());

  for (int i = 0; i < 100; i++ ) {
    try {
      s3.getObjectMetadata("test-bucket", "test-key");
    } catch (AmazonServiceException e) {
      assertThat(e.getStatusCode()).isEqualTo(404);
    }

    Thread.sleep(50);
  }
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:15,代码来源:HystrixS3DecoratorTest.java

示例3: itDoesntCount403AsFailure

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
@Test
public void itDoesntCount403AsFailure() throws InterruptedException {
  AmazonS3 s3 = HystrixS3Decorator.decorate(new NotAuthedS3Client());

  for (int i = 0; i < 100; i++ ) {
    try {
      s3.getObjectMetadata("test-bucket", "test-key");
    } catch (AmazonServiceException e) {
      assertThat(e.getStatusCode()).isEqualTo(403);
    }

    Thread.sleep(50);
  }
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:15,代码来源:HystrixS3DecoratorTest.java

示例4: itDoesntCount404AsFailure

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
@Test
public void itDoesntCount404AsFailure() throws InterruptedException {
  AmazonS3 s3 = FailsafeS3Decorator.decorate(new MissingS3Client());

  for (int i = 0; i < 100; i++ ) {
    try {
      s3.getObjectMetadata("test-bucket", "test-key");
    } catch (AmazonServiceException e) {
      assertThat(e.getStatusCode()).isEqualTo(404);
    }

    Thread.sleep(50);
  }
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:15,代码来源:FailsafeS3DecoratorTest.java

示例5: itDoesntCount403AsFailure

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
@Test
public void itDoesntCount403AsFailure() throws InterruptedException {
  AmazonS3 s3 = FailsafeS3Decorator.decorate(new NotAuthedS3Client());

  for (int i = 0; i < 100; i++ ) {
    try {
      s3.getObjectMetadata("test-bucket", "test-key");
    } catch (AmazonServiceException e) {
      assertThat(e.getStatusCode()).isEqualTo(403);
    }

    Thread.sleep(50);
  }
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:15,代码来源:FailsafeS3DecoratorTest.java

示例6: S3RangedReadObjectChannel

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
public S3RangedReadObjectChannel(String key, String bucket, AmazonS3 s3) {
    super(key, bucket, s3);
    metadata = s3.getObjectMetadata(bucket, key);
    size = metadata.getContentLength();
}
 
开发者ID:mentegy,项目名称:s3-channels,代码行数:6,代码来源:S3RangedReadObjectChannel.java

示例7: getPartCount

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
/**
 * Returns the part count of the object represented by the getObjectRequest.
 *
 * @param getObjectRequest
 * 					The request to check.
 * @param s3
 * 					The Amazon s3 client.
 *
 * @return  The number of parts in the object if it is multipart object, otherwise returns null.
 */
public static Integer getPartCount(GetObjectRequest getObjectRequest, AmazonS3 s3) {
    ValidationUtils.assertNotNull(s3, "S3 client");
    ValidationUtils.assertNotNull(getObjectRequest, "GetObjectRequest");

    ObjectMetadata metadata = s3.getObjectMetadata(new GetObjectMetadataRequest(getObjectRequest.getBucketName(), getObjectRequest.getKey(), getObjectRequest.getVersionId())
            .withSSECustomerKey(getObjectRequest.getSSECustomerKey())
            .withPartNumber(1));
    return metadata.getPartCount();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:20,代码来源:ServiceUtils.java

示例8: getLastByteInPart

import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
/**
 * Returns the last byte number in a part of an object.
 *
 * @param s3
 *             The Amazon s3 client.
 * @param getObjectRequest
 *             The request to check.
 * @param partNumber
 *             The part in which we need the last byte number.
 * @return
 *         The last byte number in the part.
 */
public static long getLastByteInPart(AmazonS3 s3, GetObjectRequest getObjectRequest, Integer partNumber) {
    ValidationUtils.assertNotNull(s3, "S3 client");
    ValidationUtils.assertNotNull(getObjectRequest, "GetObjectRequest");
    ValidationUtils.assertNotNull(partNumber, "partNumber");

    ObjectMetadata metadata = s3.getObjectMetadata(new GetObjectMetadataRequest(getObjectRequest.getBucketName(), getObjectRequest.getKey(), getObjectRequest.getVersionId())
            .withSSECustomerKey(getObjectRequest.getSSECustomerKey())
            .withPartNumber(partNumber));
    return metadata.getContentRange()[1];
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:23,代码来源:ServiceUtils.java


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