mirror of
https://github.com/penpot/penpot.git
synced 2025-01-27 00:49:28 -05:00
🐛 Fix prefix bug on s3 storage backend.
This commit is contained in:
parent
195fb3b29d
commit
25177898e1
1 changed files with 9 additions and 7 deletions
|
@ -55,8 +55,9 @@
|
||||||
(s/keys :opt-un [::region ::bucket ::prefix]))
|
(s/keys :opt-un [::region ::bucket ::prefix]))
|
||||||
|
|
||||||
(defmethod ig/prep-key ::backend
|
(defmethod ig/prep-key ::backend
|
||||||
[_ cfg]
|
[_ {:keys [prefix] :as cfg}]
|
||||||
(merge {:prefix ""} (d/without-nils cfg)))
|
(cond-> (d/without-nils cfg)
|
||||||
|
prefix (assoc :prefix prefix)))
|
||||||
|
|
||||||
(defmethod ig/init-key ::backend
|
(defmethod ig/init-key ::backend
|
||||||
[_ cfg]
|
[_ cfg]
|
||||||
|
@ -75,7 +76,8 @@
|
||||||
(s/def ::client #(instance? S3Client %))
|
(s/def ::client #(instance? S3Client %))
|
||||||
(s/def ::presigner #(instance? S3Presigner %))
|
(s/def ::presigner #(instance? S3Presigner %))
|
||||||
(s/def ::backend
|
(s/def ::backend
|
||||||
(s/keys :req-un [::region ::bucket ::client ::type ::presigner ::prefix]))
|
(s/keys :req-un [::region ::bucket ::client ::type ::presigner]
|
||||||
|
:opt-un [::prefix]))
|
||||||
|
|
||||||
;; --- API IMPL
|
;; --- API IMPL
|
||||||
|
|
||||||
|
@ -116,7 +118,7 @@
|
||||||
|
|
||||||
(defn- put-object
|
(defn- put-object
|
||||||
[{:keys [client bucket prefix]} {:keys [id] :as object} content]
|
[{:keys [client bucket prefix]} {:keys [id] :as object} content]
|
||||||
(let [path (str prefix "-" (impl/id->path id))
|
(let [path (str prefix (impl/id->path id))
|
||||||
mdata (meta object)
|
mdata (meta object)
|
||||||
mtype (:content-type mdata "application/octet-stream")
|
mtype (:content-type mdata "application/octet-stream")
|
||||||
request (.. (PutObjectRequest/builder)
|
request (.. (PutObjectRequest/builder)
|
||||||
|
@ -134,7 +136,7 @@
|
||||||
[{:keys [client bucket prefix]} {:keys [id]}]
|
[{:keys [client bucket prefix]} {:keys [id]}]
|
||||||
(let [gor (.. (GetObjectRequest/builder)
|
(let [gor (.. (GetObjectRequest/builder)
|
||||||
(bucket bucket)
|
(bucket bucket)
|
||||||
(key (str prefix "-" (impl/id->path id)))
|
(key (str prefix (impl/id->path id)))
|
||||||
(build))
|
(build))
|
||||||
obj (.getObject ^S3Client client gor)]
|
obj (.getObject ^S3Client client gor)]
|
||||||
(io/input-stream obj)))
|
(io/input-stream obj)))
|
||||||
|
@ -147,7 +149,7 @@
|
||||||
(us/assert dt/duration? max-age)
|
(us/assert dt/duration? max-age)
|
||||||
(let [gor (.. (GetObjectRequest/builder)
|
(let [gor (.. (GetObjectRequest/builder)
|
||||||
(bucket bucket)
|
(bucket bucket)
|
||||||
(key (str prefix "-" (impl/id->path id)))
|
(key (str prefix (impl/id->path id)))
|
||||||
(build))
|
(build))
|
||||||
gopr (.. (GetObjectPresignRequest/builder)
|
gopr (.. (GetObjectPresignRequest/builder)
|
||||||
(signatureDuration max-age)
|
(signatureDuration max-age)
|
||||||
|
@ -160,7 +162,7 @@
|
||||||
[{:keys [bucket client prefix]} ids]
|
[{:keys [bucket client prefix]} ids]
|
||||||
(let [oids (map (fn [id]
|
(let [oids (map (fn [id]
|
||||||
(.. (ObjectIdentifier/builder)
|
(.. (ObjectIdentifier/builder)
|
||||||
(key (str prefix "-" (impl/id->path id)))
|
(key (str prefix (impl/id->path id)))
|
||||||
(build)))
|
(build)))
|
||||||
ids)
|
ids)
|
||||||
delc (.. (Delete/builder)
|
delc (.. (Delete/builder)
|
||||||
|
|
Loading…
Add table
Reference in a new issue