S3 Presign Head method
Describe the feature
Now there is possibility to presign url for get/post/put/delete but I miss HEAD method. It is also possible using v1 sdk.
Use Case
Generate presign url to s3 object for HEAD method.
Proposed Solution
No response
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
AWS Java SDK version used
2.24.7
JDK version used
17
Operating System and version
docker and amazon corretto 17
@bartekbluestone can you tell us more about your use case?
How would you use the presigned head request?
Hi! In our app we generate urls for our clients. On of methods that they requested is HEAD and we added it few months ago, but in meantime we updated app and its dependecies, and also migrated aws sdk 1 to aws sdk 2. Previous sdk allowed us to prepare such presign url for head, and as I checked, go sdk also allow to create such request.
My use case is I want to generate a head request and a get request for downloading an object from s3. the client makes a head request to poll until the file to download is actually available.
It would be nicer if S3 just let me do a HEAD request on a presigned GET url (which from my reading of the HTTP spec... it should). But since the http method is included in the signature, making a HEAD request to a GET url will return a 403.
The absence of this functionality is a bit of a blocker to migrating to the v2 SDK from V1, since the V1 SDK supports creating these urls.
Thank you for all the inputs. We've added this to our backlog.
For my use case it would also be nice if I could use a GetObjectRequest to generate the signed HEAD url, either directly, or by having some way to convert a GetObjectRequest to a HeadObjectRequest.
For my use case, we are using chunk download and need to use the HEAD request to get the content length of the file.
+1
Also adding a +1 here - would be really helpful for us
Yes. Please. This is stopping us from migrating to v2.
Presigned HeadObject and HeadBucket requests are now supported, released in version 2.31.66.
Usage Example:
S3Presigner presigner = S3Presigner.create();
PresignedHeadObjectRequest presigned =
presigner.presignHeadObject(r -> r.signatureDuration(Duration.ofMinutes(30))
.headObjectRequest(hor -> hor
.bucket(testBucket)
.key(testGetObjectKey)));
SdkHttpClient httpClient = ApacheHttpClient.builder().build(); // or UrlConnectionHttpClient.builder().build()
HttpExecuteRequest request = HttpExecuteRequest.builder()
.request(presigned.httpRequest())
.build();
HttpExecuteResponse response = httpClient.prepareRequest(request).call();
String contentLength = response.httpResponse().firstMatchingHeader("Content-Length").orElse("0");
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.