-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
pass x-amz-meta-* headers to the getPresignedUrl api call #502
Comments
The Metadata parameter allows you to pass |
Yes, that is my understanding. In this case, I'm sending the signed url to On Monday, February 9, 2015, Loren Segal notifications@github.com wrote:
|
I tried passing Metadata to the getSignedUrl function but it throws an exception: uncaughtException: Unexpected key 'Metadata' found in params |
I'm not sure which operation you are calling. You can see an example of the |
S3 allows an x-amz-meta-* query param to be passed along with a GET request to a signed url as long as this parameter is signed with the request. What I'd like to do is use this mechanism to insert an id field that someone following the signed url cannot remove. The S3 docs suggest using an x-* query parameter to accomplish this (http://docs.aws.amazon.com/AmazonS3/latest/dev/LogFormat.html#LogFormatCustom). The drawback of doing this is that if the parameter is not in the signature, it can be removed. This is possible with other S3 api implementations. It doesn't seem like its currently possible with the aws-sdk, can you verify this is the case? If not, is it something that would be considered for addition? |
From the S3 Object and Metadata documentation
This clarifies what @lsegal said about only being able to pass metadata with I hope this helps clarify things! |
@fantapop there is no explicit support for adding arbitrary query strings to a pre-signed URL in the JS SDK, but you can use the request event cycle to add any query string values you want directly to the path. The following will ensure that your generated URL will contain var s3 = new AWS.S3({region: 'my-bucket-region', signatureVersion: 'v4'});
var req = s3.getObject({Bucket: 'mybucket', Key: 'mykey'});
req.on('build', function() { req.httpRequest.path += '?x-foo=value'; });
console.log(req.presign()); Note that you must use v4 signing when generating this URL as our S3 signer does not enforce the query string params in this way. |
sweet. Thats what I'm looking for. Thank you. On Thu, Feb 12, 2015 at 1:13 AM, Loren Segal notifications@github.com
|
this worked, thanks for the work-around. On Thu, Feb 12, 2015 at 10:17 AM, Christopher Fitzner <
|
@fantapop |
Not clear for me.
I wonder which part of the AWS document describe this. A part of code from RestUtils in AWS SDK java does this but I couldn't found certain evidence in documents. // Any parameters that are prefixed with "x-amz-" need to be included
// in the headers section of the canonical string to sign
for (Map.Entry<String, String> parameter: request.getParameters().entrySet()) {
if (parameter.getKey().startsWith("x-amz-")) {
interestingHeaders.put(parameter.getKey(), parameter.getValue());
}
} x-amz- query parameters is undocumented stuff? |
how can we change the metadata of an s3 object from Content-Type - 'video/mp4' to 'application/zip' using a lambda function? ` var params = {
this is how i am trying to do it. Can someone please help? Thanks |
@honey303 Note that |
@chrisradek Thanks for your help :) Turns out my code was indeed right, except that I had to add |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Is there a way of passing custom headers to getPresignedUrl? I'd like to pass an id field along with the presigned url so that I can correlate requests to the url with the S3 logs. I can do this using custom signing code to add the addtional header into the toSign string but the aws-sdk doesn't seem to like this.
The text was updated successfully, but these errors were encountered: