在 Java 中签署 AWS S3 link(包括版本控制)

Sign AWS S3 link (including versioning) in Java

我有以下代码将 URL 签名到 S3 Bucket

中的对象

https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURLJavaSDK.html

现在,如果 Bucket 启用了版本控制,我如何才能签署对象的特定版本 link?

呼叫withVersionId(String):

GeneratePresignedUrlRequest generatePresignedUrlRequest = 
                new GeneratePresignedUrlRequest(bucketName, objectKey)
                .withMethod(HttpMethod.GET)
                .withExpiration(expiration)
                .withVersionId("yourVesionId");

Sets the version ID of the object, only present if versioning has been enabled for the bucket.