nathancolgate / s3-swf-upload-plugin

A rails 3 gem which allow user upload files to S3 through an embedded flash directly. All UI has been moved out of flex and can be controlled by CSS and JavaScript callbacks.
http://www.nathancolgate.com
MIT License
317 stars 74 forks source link

Changing the Content Disposition Header #29

Closed kungpoo closed 13 years ago

kungpoo commented 13 years ago

I'm having trouble changing one of the headers set in s3_uploads_controller.rb After making the change the upload no longer works.

Specifically line 30

{'Content-Disposition': 'attachment'},

to

{'Content-Disposition': 'attachment; filename=test.jpg'},

I want to see if it's possible to store the keys by their ID in the database rather than the filename, then when they are requested for download by paperclip use the original filename. The explanation can be found here.

kungpoo commented 13 years ago

I'm assuming that this has something to do with it?

postVariables["Content-Disposition"]  = "attachment";

Which hardcodes 'attachment' on line 173 in the S3UploadRequest.as file

kungpoo commented 13 years ago

I can confirm that the swf is the problem, I've hacked together a solution but will tidy it up and fork the project soon.

You should change it to

postVariables["Content-Disposition"]  = _options.ContentDisposition;

then in S3Signature.as add

upload_options.ContentDisposition = xml.contentdisposition;

then recompile the swf.

Now you can add

content_disposition = "attachment; filename=#{key}"

in s3_uploads_controller.rb, along with

{'Content-Disposition': '#{content_disposition}'},

and

:contentdisposition => content_disposition
}.to_xml

Sorry it's badly formatted and quick I just wanted to put the answer out quickly incase anyone else is stuck as I'm very busy at the moment.