-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to generate S3 put object URL with metadata in the query string instead of headers #1467
Comments
Hi @alexbilbie thanks for letting us know about this issue. It looks like the metadata is being added to the URL, but it is also being included in the signature of the request. This should be investigated and see if this is a bug in the signer for presigned requests. A workaround in the short term is that the down stream client that will use the presigned URL can add the |
I've taken a look at another implementation we have written using the JavaScript SDK and that too embeds everything in the URL and doesn't require the client to send headers |
@alexbilbie after investigating this issue a bit the issue is caused by using
|
@jasdel unfortunately Here's the URL provided by
and the accompanying required headers:
Here's the URL provided by
In this case you still need to send the headers for the request to validate. |
Thanks for the update. For In investigating this we did discover an issue with sending the metadata over as query parameter with title casing causes their values to not be set on the S3 object's metadata. e.g |
Sending data to the |
…in url Updates the V4 signer so that when a Presign is generated the X-Amz-Content-Sha256 header is added to the query string instead of being required to be in the header. This allows you to generate presigned URLs for GET requests, e.g S3.GetObject that do not require additional headers to be set by the downstream users of the presigned URL. Related to aws#1467
Thanks for the update I'm investigating the |
…in url Updates the V4 signer so that when a Presign is generated the X-Amz-Content-Sha256 header is added to the query string instead of being required to be in the header. This allows you to generate presigned URLs for GET requests, e.g S3.GetObject that do not require additional headers to be set by the downstream users of the presigned URL. Related to aws#1467
…in URL (#1469) Updates the V4 signer so that when a Presign is generated the X-Amz-Content-Sha256 header is added to the query string instead of being required to be in the header. This allows you to generate presigned URLs for GET requests, e.g S3.GetObject that do not require additional headers to be set by the downstream users of the presigned URL. Related to #1467
Hi @alexbilbie I've submitted a change in #1469 that removes the need of setting This does not solve the problem of I'll reach out to S3 about the metadata query string issue letting them know. I don't think the SDK should be modified if the service can correct this issue. |
Removed the bug tag as #1469 corrects the issue with the content sha. Metadata should be included as a header for now, until S3 is able to correct the query string issue. |
Thanks for fixing the content sha issue. I don't suppose you could please explain what the PHP and JS SDKs are doing differently and why you consider this an S3 service issue? Thank you! |
The AWS SDKs for PHP and JS look to be sending the metadata name as lower cased as the query string key. This is how I discovered the issue where S3 does not correctly handle mixed case metadata name query string keys. In addition, while also investigating this issue I discovered that if unicode characters are used for metadata values the value stored on the S3 object is the URI escaped value not the unescaped value the user intended to send. I'm reaching out to S3 to see how these issues can be resolved. |
It looks like S3 does handle non-lowercase querystring keys. This is one thing preventing to SDK from sending metadata tags via the querystring. In addition we discovered that UTF-8 metadata values are represented differently in S3 if they are sent via Header vs querystring. We recommend only sending metadata via the Header which is what the SDK currently does. Because of these items I don't think the SDK can move the metadata from the Header to querystring, as S3's handling those would institute a breaking change in functionality. Let us know if you have any feedback, or additional questions about this issue. |
Thank you for the update @jasdel |
I think it would be great if the SDK could expose option (disabled by default) on the v4 |
Looks like I can actually get around this by doing the following:
|
This is actually a workaround. IMHO, the presigned url´s are useful as the clients can be agnostic of where the file is stored and how it is stored. If the client of the presigned url needs to include some random header that he doesn´t know, about, it doesn´t make any sense to include the metadata into the presigned url. |
Version of AWS SDK for Go?
v1.10.24-1-g141625ad
Version of Go (
go version
)?go1.8.3 darwin/amd64
What issue did you see?
When I use the AWS PHP SDK to generate an S3 Presigned PUT object request the metadata map is included in the query string of the generated pre-signed URL. This means that the client doesn't have to send the values of the
metadata
map asx-amz-meta-*
headers:The same code with the Go SDK generates a pre-signed URL that requires the
x-amz-meta-*
headers.This means I can't enforce the values of the metadata map.
How can I generate a URL in the same way with the Golang SDK?
Steps to reproduce
PHP SDK example:
Go SDK example:
The text was updated successfully, but these errors were encountered: