Unable to override content disposition header in s3

Question:

I’m using the following php function to give temporary access to the public for a private file.

I wanted to add the content disposition header so I can change the filename to test.mp3 when a user tries to access this url which defaults the filename to 982jdjd2p3.mp3

I tried adding the following line of code to the function

However when I click on the url

http://s3.amazonAWS.com/testbucket/982jdjd2p3.mp3?AWSAccessKeyId=***&Expires=***&Signature=***&Content-Disposition=test.mp3

The proposed filename is to be saved as 982jdjd2p3.mp3

How do I override the content disposition header for s3 GET requests using this function?

See Also

Amazon S3 Change file download name

EDIT

Here is the most recent attempt to rename the file with a get request using this function.

Answer:

The problem with your function is that the header values should be encoded in the final hyperlink, but not for signing. The following function corrects that:

Leave a Reply