clj-http

mchampine 2020-10-25T01:01:42.008700Z

Hi all. When I upload a jpeg via curl, the content-type gets set to image/jpeg.

curl -L -X POST "<https://my/url/>" -F 'file=@mypic.jpg'
but when I upload via clj-http:
(client/post "<https://my/url/>" {:multipart
             [{:name "file" :content (<http://clojure.java.io/file|clojure.java.io/file> "mypic.jpg")}]})
the file winds up as application/octet-stream. I have tried everything I can think of to specify the content type e.g. adding {:name “Content/type” :content “image/jpeg”} to the multipart vector, but to no avail. Any idea how to emulate the curl behavior here, and have the content type set correctly on file uploads? Thanks!

dharrigan 2020-10-25T07:05:13.008900Z

Set this

dharrigan 2020-10-25T07:05:31.009300Z

[{:name "file" :content (<http://clojure.java.io/file|clojure.java.io/file> "mypic.jpg") :mime-type "image/jpeg"}]})

mchampine 2020-10-25T17:50:33.010100Z

@dharrigan That worked!! Thank you!

dharrigan 2020-10-25T19:00:38.010300Z

You're most welcome 😉