ring-clojure / ring

Clojure HTTP server abstraction
MIT License
3.75k stars 519 forks source link

How do I use the wrap-multipart-params to proccess "upload file" #397

Closed nesteiner closed 4 years ago

nesteiner commented 4 years ago

when i try to use wrap-multipart-params,what i want is to upload file from form,and i need to save upload file into a designation directory. however there is no more information in the API DOC,there isn't any example for the :store option http://ring-clojure.github.io/ring/ring.middleware.multipart-params.html#var-wrap-multipart-params

weavejester commented 4 years ago

Does the wiki page on file uploads answer your question?

nesteiner commented 4 years ago

I'sure it's has solved my question a lot,but here is something left. is that means i just need to operate the :temp-file---move it?? what about that when i want to store the tempfile in a desigational directory by default

nesteiner commented 4 years ago

by the way,this page can not be founded,which is titled as example for FIle Upload https://gist.github.com/thescalaguy/c743bf7c93f6363f3d22de28c7c9bb3d

weavejester commented 4 years ago

is that means i just need to operate the :temp-file---move it??

Yes. Typically you'll validate the file in some way, then move the temporary file to wherever you want as part of your handler's logic.

what about that when i want to store the tempfile in a desigational directory by default

You could write your own custom store, but it's easier just to move the temporary file.