I'm not sure how that would be handled with noir.
With plain ring, you would use the multipart-params middleware [1] to get a
:multipart-params submap in the request, in which all uploaded files are
passed.
At this point you can process them with

(doseq [[param-name {:keys [filename content-type bytes]}]
(:multipart-params request)]
  ...) ;; if you used multipart-params.byte-array, or
(doseq [[param-name {:keys [filename content-type tempfile size]}]
(:multipart-params request)]
  ...) ;; if you used multipart-params.temp-file

[1] http://ring-clojure.github.io/ring/ring.middleware.multipart-params.html


2014-08-03 23:46 GMT+02:00 Nick Macia <nickhocke...@gmail.com>:

> Hello all, sorry that this is a basic question. I've recently migrated
> over to clojure from php and some features of the language still remain
> obscure to me. I have been following "Web Development with Clojure" (solid
> intro) and have run into a wall with file uploads. The book provides the
> following code to handle uploads:
>
> (defn handle-upload [{:keys [filename] :as file}]
>   (show-upload
>    (if (empty? filename)
>      "please select a file to upload"
>
>      (try
>        (noir.io/upload-file (sb) file :create-path? true)
>        (image {:height "150px"}
>               (str "/img/" (url-encode filename)))
>
>      (catch Exception ex
>        (str "error uploading file " (.getMessage ex)))))))
>
> I would like to know how to generalize this in order to process multiple
> files. In php, this would just be a for-each loop, but I am still searching
> for that loop analogue in clojure. Any help would be great. Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to