I have a file input setup like this
[:p "Upload a book"]
(form-to [:post "/upload"]
(file-upload :book)
(submit-button "Upload"))
My upload endpoint then looks like this.
(defpage [:post "/upload"] {:keys [book]} (println book))
book just seems to be a string of the title of the file that was uploaded and not the file itself. How do I get the file?
According to this thread (see second post by Chris Granger):
you can use something like:
(defpage [:post "upload"] {:keys [myFile]}
(println myFile) ;; see all the things the file contains
(io/copy (io/file (:tempfile myFile)) (io/file "uploads/some-new-name")))
Here's a gist from this thread:
with a note (again from Chris) that you need Leiningen 1.6.1.1+ not to run into a bug.
You can see a similar thing (though for Amazon S3) here:
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With