mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 14:18:24 +02: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
|
;; --- Create Image
|
||||||
|
|
||||||
|
(def allowed-file-types #{"image/jpeg" "image/png"})
|
||||||
|
|
||||||
(defrecord CreateImages [coll-id files]
|
(defrecord CreateImages [coll-id files]
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [_ state s]
|
(-apply-watch [_ state s]
|
||||||
(letfn [(image-size [file]
|
(letfn [(image-size [file]
|
||||||
(->> (files/get-image-size file)
|
(->> (files/get-image-size file)
|
||||||
(rx/map (partial vector file))))
|
(rx/map (partial vector file))))
|
||||||
|
(allowed-file? [file]
|
||||||
|
(contains? allowed-file-types (.-type file)))
|
||||||
(prepare [[file [width height]]]
|
(prepare [[file [width height]]]
|
||||||
{:coll coll-id
|
{:coll coll-id
|
||||||
:id (uuid/random)
|
:id (uuid/random)
|
||||||
|
@ -204,6 +208,7 @@
|
||||||
:width width
|
:width width
|
||||||
:height height})]
|
:height height})]
|
||||||
(->> (rx/from-coll (jscoll->vec files))
|
(->> (rx/from-coll (jscoll->vec files))
|
||||||
|
(rx/filter allowed-file?)
|
||||||
(rx/flat-map image-size)
|
(rx/flat-map image-size)
|
||||||
(rx/map prepare)
|
(rx/map prepare)
|
||||||
(rx/flat-map #(rp/req :create/image %))
|
(rx/flat-map #(rp/req :create/image %))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue