diff --git a/src/uxbox/data/images.cljs b/src/uxbox/data/images.cljs index 3753e59b0..729c0e8c1 100644 --- a/src/uxbox/data/images.cljs +++ b/src/uxbox/data/images.cljs @@ -171,10 +171,16 @@ (defrecord CreateImages [coll-id files] rs/WatchEvent (-apply-watch [_ state s] - (let [image-data {:coll coll-id - :id (uuid/random) - :files files}] - (->> (rp/req :create/image image-data) + (let [files-to-array (fn [js-col] + (-> (clj->js []) + (.-slice) + (.call js-col) + (js->clj))) + images-data (map (fn [file] {:coll coll-id + :id (uuid/random) + :file file}) (files-to-array files))] + (->> (rx/from-coll images-data) + (rx/flat-map #(rp/req :create/image %)) (rx/map :payload) (rx/map image-created))))) diff --git a/src/uxbox/repo/images.cljs b/src/uxbox/repo/images.cljs index b5e4aa03b..98ceb6898 100644 --- a/src/uxbox/repo/images.cljs +++ b/src/uxbox/repo/images.cljs @@ -46,9 +46,9 @@ (send! params))) (defmethod request :create/image - [_ {:keys [coll id files] :as body}] + [_ {:keys [coll id file] :as body}] (let [body (doto (js/FormData.) - (.append "file" (aget files 0)) + (.append "file" file) (.append "id" id)) params {:url (str url "/library/image-collections/" coll "/images") :method :post diff --git a/src/uxbox/ui/dashboard/images.cljs b/src/uxbox/ui/dashboard/images.cljs index 9db0bf5ab..abf457f52 100644 --- a/src/uxbox/ui/dashboard/images.cljs +++ b/src/uxbox/ui/dashboard/images.cljs @@ -208,6 +208,7 @@ [:span "+ New image"] [:input.upload-image-input {:style {:display "none"} + :multiple true :ref "file-input" :type "file" :on-change on-file-selected}]])