Skip to content

Add response headers to presigned URL v4#277

Open
mortenpi wants to merge 2 commits intoJuliaCloud:masterfrom
mortenpi:mp/add-response-header-overrides
Open

Add response headers to presigned URL v4#277
mortenpi wants to merge 2 commits intoJuliaCloud:masterfrom
mortenpi:mp/add-response-header-overrides

Conversation

@mortenpi
Copy link

This adds support for response-* query parameters for overriding response headers in v4 presigned URLs.

Right now, you can pass content_type to s3_sign_url, but it only does something for v2, and in v4 it is ignored. So here I am adding Content-Type + all the other supported ones, but only to v4 (as the v2 version seems to be deprecated).

It was a bit of a trial and error to figure out how exactly they should be incorporated into the signing process, but it seems to work:

AWSS3.s3_sign_url(
    aws_config, bucket, key, 60;
    verb="GET",
    signature_version="v4",
    protocol="https",
    content_type = "text/html",
    content_disposition = "attachment",
    content_language = "de-DE, en-CA",
    expires = Dates.format(now() + Dates.Hour(1), Dates.RFC1123Format),
    cache_control = "private, no-cache, no-store",
    content_encoding = "deflate",
)

leads to the following response when GETed:

HTTP/1.1 200 OK
x-amz-id-2: ...
x-amz-request-id: ...
Date: Fri, 27 Jan 2023 05:07:26 GMT
Last-Modified: Thu, 26 Jan 2023 00:09:10 GMT
ETag: "0797e3fead7383ee6f61c523c4582256"
x-amz-version-id: ...
Cache-Control: private, no-cache, no-store
Content-Disposition: attachment
Content-Encoding: deflate
Expires: Fri, 27 Jan 2023 19:07:24
Content-Language: de-DE, en-CA
Accept-Ranges: bytes
Content-Type: text/html
Server: AmazonS3
Content-Length: 93

If this broadly looks reasonable, them I'm happy to add some docs and tests as well.

@mortenpi mortenpi marked this pull request as draft January 27, 2023 06:32
@mortenpi mortenpi marked this pull request as ready for review November 2, 2023 06:28
@mortenpi
Copy link
Author

mortenpi commented Nov 2, 2023

Just a friendly bump -- it would still be nice to get this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant