binarygiant
binarygiant

Reputation: 6422

AWS Pre-signed PUT URL Requires &s to be Replaced with &?

I have a service that generates S3 pre-signed PUT URLS for uploading.

While testing I noticed that Postman would have no issue uploading to the pre-signed URL as long as I clicked on the URL in "Pretty" mode. This would put the URL in its address bar.

But when I copied the raw output, it would 403 every time.

Does AWS S3 require & signs to be replaced with &?

EDIT: Updating to show how pre-signed URL is fetched with Node/Express/AWS API

router.get('/', function (req, res) {
    var s3 = new AWS.S3();
    var params = {Bucket: 'some-s3-bucket', Key: 'test/'};
    s3.getSignedUrl('putObject', params, function (err, url) {
        res.json({url: url});
    });
});

This URL would produce a 403

Clicking on this replaces the & in the URL to &

This URL would work

Upvotes: 1

Views: 1458

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179194

No, you shouldn't html-encode && in the query string separators in an S3 signed URL.

It sounds like your service is generating the urls and either it, or something in the chain, is incorrectly html-encoding them, and by luck, postman or the browser is cleaning them back up again when you view them in "pretty" mode.

If you're deliberately doing this, then don't... but if you're unclear where the spurious encoding is coming from, switching to a text based tool for talking to your service -- like curl or wget -- is likely to get you closer to understanding what's going on than a browser-based tool.

Upvotes: 1

Related Questions