martinklepsch / s3-beam

🚀 direct-to-S3 uploading using ClojureScript
Eclipse Public License 1.0
92 stars 17 forks source link

setting "Content-Dispoition": "attachment" ? #42

Open jdkealy opened 7 years ago

jdkealy commented 7 years ago

Hi,

I've been trying for a few hours now to set the metadata "Content-Disposition": "attachment" in S3. I'm trying to enforce that all images / videos are downloaded when one navigates to them in s3. I can't seem to get this to work with either header-fn or with metadata. Do you have any suggestions on how to set this header for S3 objects? Thanks!

jdkealy commented 7 years ago

I've tried the following

(dissoc
   (s3b/sign-upload
    {:file-name "foobar.jpg"
     :mime-type "jpg"
     :Content-Disposition "attachment"
     :headers {:metadata {:Content-Disposition "attachment"}}

     }
    {:bucket "blabla"
     :aws-key "blabla"
     :aws-zone "us-east-1"
     :aws-secret-key "blabla"})
   :action 
   :api_key)

no luck... setting the content disposition then in CLJS throws the error that the params don't match the presigned url.

danielcompton commented 7 years ago

Have you seen this? https://github.com/martinklepsch/s3-beam/commit/21bc14e7f7b5d80e682afe803b7779146010a4c2

jdkealy commented 7 years ago

I'm not really using the pipeline functions so correct me if I'm wrong I should be able to do this?

(s3b/sign-upload (assoc newp :metadata {:content-disposition "attachment"}) {:bucket "bucket" :aws-key "abc" :aws-zone "us-east-1" :aws-secret-key "defg"})

and then add another form field for metadata on the cljs side of things ?

jdkealy commented 7 years ago

I've done the above on the CLJ side of things, then in cljs i have tried appending the params with :metadata {:content-disposition "attachment"} but get back from amazon:

Invalid according to Policy: Extra input fields: :metadata Invalid according to Policy: Extra input fields: :content-disposition

I realized then I needed to assoc "metadata" instead of :metadata but still get

Invalid according to Policy: Extra input fields: content-disposition Invalid according to Policy: Extra input fields: metadata

Still pretty confused :/