0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-03 11:25:27 -05:00
penpot/backend/src/uxbox/media.clj

42 lines
1.2 KiB
Clojure
Raw Normal View History

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
2017-01-22 15:50:00 +01:00
;; Copyright (c) 2017 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.media
"A media storage impl for uxbox."
(:require [mount.core :refer [defstate]]
[clojure.java.io :as io]
[cuerdas.core :as str]
[datoteka.storages :as st]
[datoteka.storages.local :refer [localfs]]
[datoteka.storages.misc :refer [hashed scoped]]
[uxbox.config :refer [config]]))
2017-01-22 15:50:00 +01:00
;; --- State
2017-01-22 15:50:00 +01:00
(defstate assets-storage
:start (localfs {:basedir (:assets-directory config)
2019-07-05 09:41:02 +02:00
:baseuri (:assets-uri config)
:transform-filename str/uslug}))
(defstate media-storage
2017-01-22 15:50:00 +01:00
:start (localfs {:basedir (:media-directory config)
2019-07-05 09:41:02 +02:00
:baseuri (:media-uri config)
:transform-filename str/uslug}))
(defstate images-storage
:start (-> media-storage
(scoped "images")
(hashed)))
(defstate thumbnails-storage
:start (scoped media-storage "thumbs"))
;; --- Public Api
(defn resolve-asset
[path]
2017-01-22 15:50:00 +01:00
(str (st/public-url assets-storage path)))