使用适用于Java 2.x的AWS开发工具包检查S3对象的元数据 [英] Check metadata of S3 objects with AWS SDK for Java 2.x
本文介绍了使用适用于Java 2.x的AWS开发工具包检查S3对象的元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到用使用适用于Java 1.x的AWS开发工具包,就这么简单:
With the AWS SDK for Java 1.x it was as easy as this:
s3Client.getObjectMetadata("myBucket","myfile.doc");
s3Client.getObjectMetadata("myBucket", "myfile.doc");
但是我看不到最新版本的API的类似方法.
But I cannot see the analogous method for the newest version of the API.
推荐答案
解决方案是使用HeadObjectRequest
和HeadObjectResponse
:
HeadObjectRequest headObjectRequest = HeadObjectRequest.builder()
.bucket(bucketName)
.key(key)
.build();
然后:
HeadObjectResponse headObjectResponse = s3Client.headObject(headObjectRequest);
System.out.println("This is what I need: " + headObjectResponse.contentType());
这篇关于使用适用于Java 2.x的AWS开发工具包检查S3对象的元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文