Skip to content

Conversation

@RanVaknin
Copy link
Contributor

Builds upon work done in #5476
Addresses #5473, #5276

Motivation and Context

This PR adds the possibility of presigning S3 head operations, a functionality that was supported in v1 and was creating a parity gap and preventing customers from migrating to v2.

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");

Modifications

Added presignHeadObject and presignHeadBucket methods to the S3 Presigner. That includes adding model classes for request/response (HeadObjectPresignRequest and PresignedHeadObjectRequest, HeadBucketPresignRequest and PresignedHeadBucketRequest) and adding the marshalling logic for those.

Testing

  • Unit tests: Added tests to verify HEAD operations are correctly presigned, including method types, version IDs, and expected bucket owner parameters.
  • Integration tests: Added tests to verify presigned HEAD URLs work against actual S3 for both object and bucket operations.

@RanVaknin RanVaknin requested a review from a team as a code owner June 4, 2025 18:13
@RanVaknin RanVaknin force-pushed the rvaknin/add-support-for-presigned-HEAD-urls branch from a709117 to 586cad9 Compare June 4, 2025 18:23
@RanVaknin RanVaknin changed the title Rvaknin/add support for presigned head urls rvaknin/add support for presigned head urls Jun 4, 2025
@RanVaknin RanVaknin changed the title rvaknin/add support for presigned head urls add support for presigned head urls Jun 4, 2025
@L-Applin
Copy link
Contributor

L-Applin commented Jun 6, 2025

Looks good, but I don't remember if we did a surface API review for this? I know it is just small new classes, but these are still new public APIs, do we need to do a quick one?

@RanVaknin RanVaknin force-pushed the rvaknin/add-support-for-presigned-HEAD-urls branch from 586cad9 to 8183d94 Compare June 10, 2025 18:11
@RanVaknin RanVaknin force-pushed the rvaknin/add-support-for-presigned-HEAD-urls branch from 8183d94 to 48a3fa5 Compare June 11, 2025 22:29
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
46.0% Coverage on New Code (required ≥ 80%)
8.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@RanVaknin RanVaknin added this pull request to the merge queue Jun 17, 2025
Merged via the queue into master with commit d73091d Jun 17, 2025
24 of 26 checks passed
@github-actions
Copy link

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants