mirror of
https://github.com/penpot/penpot.git
synced 2025-02-24 07:46:13 -05:00
Only allow upload a limited set of image types.
This commit is contained in:
parent
a0127130a6
commit
492e57d845
1 changed files with 5 additions and 0 deletions
|
@ -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 %))
|
||||
|
|
Loading…
Add table
Reference in a new issue