简体   繁体   English

如何使用 aws-sdk-2.x 从 S3 存储桶中获取 object 的 S3 URL

[英]How to get S3 URL for the object from S3 bucket using aws-sdk-2.x

We were using the AWS Java SDK-1.x version in our application till now.到目前为止,我们在我们的应用程序中使用的是 AWS Java SDK-1.x 版本。 We decided to migrate to the 2.x.我们决定迁移到 2.x。 As per my analysis I have found out the equivalent function which we are using for 1.x client operation in 2.x in our application.根据我的分析,我发现了等效的 function,我们在应用程序中将其用于 2.x 中的 1.x 客户端操作。 But for some operation I could not able to find matching functions.但是对于某些操作,我找不到匹配的函数。 Below are the details.以下是详细信息。

1.x (AmazonS3) 1.x (AmazonS3) 2.x (S3AsyncClient) 2.x (S3AsyncClient)
getObject(String bucket, String key) getObject(字符串桶,字符串键) getObject(GetObjectRequest req, Path destination) getObject(GetObjectRequest req, Path destination)
putObject(String bucket, String key, File file) putObject(String bucket, String key, File 文件) putObject(PutObjectRequest req, Path source) putObject(PutObjectRequest 请求,路径源)
generatePresignedUrl(GeneratePresignedUrlRequest req) generatePresignedUrl(GeneratePresignedUrlRequest 请求) S3PreSigner.presignGetObject(GetObjectPresignRequest req) S3PreSigner.presignGetObject(GetObjectPresignRequest 请求)
deleteObject(String bucket, String key) deleteObject(字符串桶,字符串键) deleteObject(DeleteObjectRequest req) deleteObject(删除对象请求请求)
getUrl(String bucket, String key) getUrl(字符串桶,字符串键) ?
doesObjectExist(String bucket, String key) doesObjectExist(字符串桶,字符串键) ?

Any help or pointer is really appreciated.非常感谢任何帮助或指示。

Below are the replacements for the methods that you are looking for in 2.x SDK:以下是您在 2.x SDK 中寻找的方法的替代品:

1.11.x Operation 1.11.x 操作 2.0 Operation 2.0操作
getUrl S3Utilities#getUrl S3Utilities#getUrl
doesObjectExist headObject

Here is a complete mapping of S3 1.x and 2.0 Operations .这是S3 1.x 和 2.0 操作的完整映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM