Hello,

Thank you for the great module. One need we have is in using UC File S3 to serve large downloadable files through S3. Unfortunately each file wants to open in the browser (especially if it's an mp3 or a wmv, for instance). According to the S3 API docs here: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html as well as an AWS developer I chatted with, you can only set content-disposition in a signed URL.

Since there doesn't seem to be any way (yet) to send additional parameters to the getAuthenticatedUrl static function, attached is a patch that hard-codes the "response-content-disposition" parameter into the signature and URL creation process for this function.

A betters olution would be to add another param after $https that could contain additional headers to override, but this is quick and dirty - hopefully it can help others.

As soon as I think of the best way to add more params to the function, I will post an updated patch - or we can create a new issue and patch for that, if preferred.

Comments

torgospizza’s picture

Status: Active » Needs review

Setting to needs review as there is a patch here, but I'm open to suggestions to make it better. Thanks!

torgospizza’s picture

Project: Amazon S3 File Downloads for Ubercart » Amazon S3
Version: » 6.x-1.0

Whoops - moving to Amazon S3 issue queue.

torgospizza’s picture

StatusFileSize
new1.64 KB

Here's a better patch that allows any module to send header overrides as an array ($key => $value pair). I've tested it successfully with multiple headers being overridden. There are 6 you can override, according to the Amazon API docs (http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html) but I didn't feel we needed to test for them. Any module implementing header overrides can take a look at that URL to see what they're allowed to specify.

torgospizza’s picture

StatusFileSize
new1.77 KB

Ugh, had some whitespace / tab issues in that last patch. Here's one without such problems.

torgospizza’s picture

Title: Set response-content-disposition parameter to force download of getAuthenticatedUrl » Allow modules to override default headers of signed URLs in getAuthenticatedUrl

Changing the title to better reflect the latest patch.

venkatd’s picture

Hi,

Sorry for the lack of responses as I have been busy with other projects. Could you please apply the patch? I currently have no motivation Amazon S3 and don't have a CVS client installed :(.

You have my permission to become a co-maintainer.

-Venkat

torgospizza’s picture

I would love to! Many thanks for the CVS access.

torgospizza’s picture

Hi, I just tried to commit and I got access denied. Would you mind adding me to the list of maintainers? (You just need to Edit the project and go to the Maintainers tab.) I have the revision ready to go. :)

Thanks!

torgospizza’s picture

StatusFileSize
new1.75 KB

The following attach is better; I ran into an issue when a module did not require any overrides, there was an ampersand hard-coded into the generated URL that caused the signature to be wrong. Now I'm using a tertiary condition to check the $overrides string and append it accordingly.

torgospizza’s picture

Status: Needs review » Fixed

This has been committed to CVS, revision 1.2. There seems to be an issue with the Branches and tagging in the project, so the next chance I get, I will attempt to clean that up and issue a 1.x-dev release.

torgospizza’s picture

I just realized the s3.inc file is simply the PHP class found here: http://undesigned.org.za/2007/10/22/amazon-s3-php-class - the one in the module is a slightly older version. I may want to run a diff on these and upgrade the module's s3.inc to keep up with the changes, especially if they are significant.

I created a new issue: #1051858: Upgrade to latest S3 PHP class and also emailed Donovan, the creator of the S3 PHP class, to notify him of my original patch, to see if he can include it in the original class file. That will make future upgrades to the class not require patching :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.