s3_direct_upload
s3_direct_upload copied to clipboard
How to add additional S3 metadata?
I'd like to add Content-Disposition: attachment
to all uploaded files so that if the download link is visited, browsers are forced to download the file.
For example if you hit the download URL for an mp3 without Content-Disposition: attachment
, Chrome will just stream the mp3 in the browser. But if you set Content-Disposition: attachment
, Chrome will download the file.
Thanks!
Also interested. Did you sort this out?
Nope
A quick glance at the s3 doc shows that you can pass a "Content-Disposition" field with direct uploads. So you may be able to add/remove this field from the form at runtime by inspecting the filename of the uploaded file. Perhaps in the jquery file upload "add" callback?
Thanks! Worked for me as well.
@rahilsondhi this isn't a safe way of doing this, especially because of the empty $key starts-with field (a security flaw for most applications). People may copy and paste your code frequently. Please consider updating your answer so others don't introduce this security flaw into their applications inadvertently like we almost did.
@sheharyarn please note this as well.
An example of the proper way to do this :https://github.com/waynehoover/s3_direct_upload/issues/266