AWS S3 Add paramters to signed url

Viewed 381

i use django-storages to store static and private files in a s3 bucket.

For a few files i need to pass parameters in the url because the requested html file generate dynamic content with these parameters.

For example:

https://example-static-bucket.s3.amazonaws.com/static/header.html?name=Example&site=2

With static files this works very well.

But if i fetch the signed url for a private file with django-storages and add the parameters i get an error:

<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
...
</Error>

How can i add parameters to a signed url with django-storages?

1 Answers

S3 stores static objects, you can't modify them with signed URLs. Think of S3 objects as files in a filesystem: they have a path and a name and you can get their contents, but they are a dumb container for data.

Similarly, you can not have a static/header.html to become different based on the parameters of the call. You can upload a file and you can download it, that's it.

Related