0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-24 15:56:11 -05:00

Only allow upload a limited set of image types.

This commit is contained in:
Andrey Antukh 2016-10-12 19:21:38 +02:00
parent a0127130a6
commit 492e57d845

View file

@ -191,12 +191,16 @@
;; --- Create Image
(def allowed-file-types #{"image/jpeg" "image/png"})
(defrecord CreateImages [coll-id files]
rs/WatchEvent
(-apply-watch [_ state s]
(letfn [(image-size [file]
(->> (files/get-image-size file)
(rx/map (partial vector file))))
(allowed-file? [file]
(contains? allowed-file-types (.-type file)))
(prepare [[file [width height]]]
{:coll coll-id
:id (uuid/random)
@ -204,6 +208,7 @@
:width width
:height height})]
(->> (rx/from-coll (jscoll->vec files))
(rx/filter allowed-file?)
(rx/flat-map image-size)
(rx/map prepare)
(rx/flat-map #(rp/req :create/image %))