feat: support request headers as S3 object metadata in PUT templates#678
Conversation
bb3c692 to
51f2687
Compare
|
Hi @oxyno-zeta, I was wondering if there could be a review of this PR any time soon. I'm really looking forward to get this feature released. Thanks! |
|
Hello @argos83 @sebastian-tello , Thanks for your PR. This can be cool yes ! Look like the documentation isn't fully updated as structure.md and templates.md are laking this part. Moreover, your changes also affect the systemMetadata part. Unfortunately I won't have a lot of time this week @sebastian-tello . I have personally issues to manage for the moment... Have a nice day ! |
089d6f4 to
4db2233
Compare
Thanks for your feedback @oxyno-zeta . I hadn't noticed this affecting systemMetadata too. I see the value of this too, systemMetadata fields were originally meant for fixed config-level values. Some reasonable use cases for RequestHeaders in systemMetadata:
The less natural ones are cacheControl and expires (those are usually a server/config policy decision, not I have updated the docs as you suggested to reflect this changes. |
|
I've started the CI for the first part. I will start it again with the missing test. But this is a cool feature to have :) . Thanks ! |
Add RequestHeaders (http.Header) to PutInput so that PUT metadata and storage class templates can access incoming request headers via .Input.RequestHeaders.Get. The lookup is case-insensitive, matching Go's standard http.Header semantics. Multi-value headers can be accessed with index and combined using sprig's join function.
4db2233 to
7a3b0ac
Compare
Test added 😊 Btw, I've been amending and force-pushing the same commit to keep implementation, docs, and tests as a single atomic changeset - wasn't sure how automated releases/changelog from conventional commits work in this project. Let me know if you'd prefer a different approach for future contributions. |
|
Hello @argos83 , |
|
🎉 This PR is included in version 4.20.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Issue/Feature
Adds support for forwarding PUT request headers as S3 object metadata via Go templates. This enables use cases such as attaching tracing/correlation data or uploader identity to S3 objects at upload time.
In my particular case s3-proxy is accessed via a tool running in CI which needs to include metadata for git-commit and build-url to objects store in S3. Without this change there's no way to pass custom dynamic values for object metadata.
Additional Information
What:
PutInputnow exposesRequestHeaders(http.Header) so that PUT metadata and storageclass templates can access incoming request headers.
How: Templates use
.Input.RequestHeaders.Get "X-Header-Name"for case-insensitive single-valueaccess, or
{{ join "," (index .Input.RequestHeaders "X-Header-Name") }}to retrieve all values of amulti-value header (via Sprig's
join).Example configuration:
GET/HEAD responses already exposed S3 metadata via
.StreamFile.Metadata; this change closes the gapon the PUT side.
Verification Steps
putaction and ametadatatemplate using.Input.RequestHeaders.Get "X-My-Header"X-My-Header: some-valuein the requestx-my-headershould be set tosome-valueChecklist: