最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - AWS Java S3 SDK version 2 alternative for ResponseHeaderOverrides - Stack Overflow

programmeradmin1浏览0评论

We currently use AWS Java S3 SDK version 1 for generating presigned GET links for our S3 buckets. For our customers we include the ability to set the output contentType and contentDisposition for the returned content of the presigned.

To do this we do the following:

headerOverrides.setContentType(contentType);
headerOverrides.setContentDisposition(contentDisp);
generatePresignedUrlRequest.setResponseHeaders(headerOverrides);

I have been unable to find the equivalent mechanism for this in the v2 SDK.

If someone could provide the v2 equivalent for setting these response headers as implemented in the Java S3 SDK version 2 - definitely appreciate!

So far AwsRequestOverrideConfiguration looks like a possibility - will continue experimenting.

We currently use AWS Java S3 SDK version 1 for generating presigned GET links for our S3 buckets. For our customers we include the ability to set the output contentType and contentDisposition for the returned content of the presigned.

To do this we do the following:

headerOverrides.setContentType(contentType);
headerOverrides.setContentDisposition(contentDisp);
generatePresignedUrlRequest.setResponseHeaders(headerOverrides);

I have been unable to find the equivalent mechanism for this in the v2 SDK.

If someone could provide the v2 equivalent for setting these response headers as implemented in the Java S3 SDK version 2 - definitely appreciate!

So far AwsRequestOverrideConfiguration looks like a possibility - will continue experimenting.

Share Improve this question asked Jan 29 at 17:47 David LoyDavid Loy 211 silver badge1 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Discovered Version 2 of the AWS S3 Java SDK has moved the overrides directly to GetObjectRequest.

    GetObjectRequest getObjectRequestgetObjectRequest =
          GetObjectRequest.builder()
                          .bucket(bucketName)
                          .key(keyName)
                  .responseContentType(contentType)
                  .responseContentDisposition(contentDisposition)
                          .build();
        
           

     // Create a GetObjectPresignRequest to specify the signature duration
    GetObjectPresignRequest getObjectPresignRequest =
        GetObjectPresignRequest.builder()
                             .signatureDuration(Duration.ofMillis(expirationMs))
                             .getObjectRequest(getObjectRequest)
                             .build();
发布评论

评论列表(0)

  1. 暂无评论