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 badge1 Answer
Reset to default 0Discovered 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();