s3_direct_upload icon indicating copy to clipboard operation
s3_direct_upload copied to clipboard

How to add additional S3 metadata?

Open rahilsondhi opened this issue 12 years ago • 5 comments

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!

rahilsondhi avatar Dec 22 '12 01:12 rahilsondhi

Also interested. Did you sort this out?

uberllama avatar Jan 19 '13 22:01 uberllama

Nope

rahilsondhi avatar Jan 19 '13 22:01 rahilsondhi

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?

uberllama avatar Jan 19 '13 22:01 uberllama

Thanks! Worked for me as well.

sheharyarn avatar Dec 05 '13 19:12 sheharyarn

@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

maxhudson avatar Feb 01 '18 20:02 maxhudson