mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 00:36:11 +02:00
✨ Avoid reflection on s3 storage backend.
This commit is contained in:
parent
34e5e5c513
commit
ef25f8a721
2 changed files with 15 additions and 9 deletions
|
@ -26,7 +26,10 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[integrant.core :as ig]
|
[integrant.core :as ig]
|
||||||
[lambdaisland.uri :as u]
|
[lambdaisland.uri :as u]
|
||||||
[promesa.exec :as px]))
|
[promesa.exec :as px])
|
||||||
|
(:import
|
||||||
|
java.io.InputStream))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Storage Module State
|
;; Storage Module State
|
||||||
|
@ -159,8 +162,9 @@
|
||||||
|
|
||||||
;; if the source and destination backends are different, we just
|
;; if the source and destination backends are different, we just
|
||||||
;; need to obtain the streams and proceed full copy of the data
|
;; need to obtain the streams and proceed full copy of the data
|
||||||
(with-open [input (-> (resolve-backend storage (:backend object))
|
(with-open [^InputStream input
|
||||||
(impl/get-object-data object))]
|
(-> (resolve-backend storage (:backend object))
|
||||||
|
(impl/get-object-data object))]
|
||||||
(-> (resolve-backend storage (:backend storage))
|
(-> (resolve-backend storage (:backend storage))
|
||||||
(impl/put-object object* (impl/content input (:size object))))))
|
(impl/put-object object* (impl/content input (:size object))))))
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
java.io.InputStream
|
java.io.InputStream
|
||||||
java.io.OutputStream
|
java.io.OutputStream
|
||||||
java.nio.file.Path
|
java.nio.file.Path
|
||||||
|
java.time.Duration
|
||||||
|
java.util.Collection
|
||||||
software.amazon.awssdk.core.sync.RequestBody
|
software.amazon.awssdk.core.sync.RequestBody
|
||||||
software.amazon.awssdk.regions.Region
|
software.amazon.awssdk.regions.Region
|
||||||
software.amazon.awssdk.services.s3.S3Client
|
software.amazon.awssdk.services.s3.S3Client
|
||||||
|
@ -105,7 +107,7 @@
|
||||||
|
|
||||||
;; --- HELPERS
|
;; --- HELPERS
|
||||||
|
|
||||||
(defn- lookup-region
|
(defn- ^Region lookup-region
|
||||||
[region]
|
[region]
|
||||||
(case region
|
(case region
|
||||||
:eu-central-1 Region/EU_CENTRAL_1))
|
:eu-central-1 Region/EU_CENTRAL_1))
|
||||||
|
@ -161,7 +163,7 @@
|
||||||
(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 ^GetObjectRequest gor)]
|
||||||
(io/input-stream obj)))
|
(io/input-stream obj)))
|
||||||
|
|
||||||
(def default-max-age
|
(def default-max-age
|
||||||
|
@ -175,10 +177,10 @@
|
||||||
(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 ^Duration max-age)
|
||||||
(getObjectRequest gor)
|
(getObjectRequest ^GetObjectRequest gor)
|
||||||
(build))
|
(build))
|
||||||
pgor (.presignGetObject ^S3Presigner presigner gopr)]
|
pgor (.presignGetObject ^S3Presigner presigner ^GetObjectPresignRequest gopr)]
|
||||||
(u/uri (str (.url ^PresignedGetObjectRequest pgor)))))
|
(u/uri (str (.url ^PresignedGetObjectRequest pgor)))))
|
||||||
|
|
||||||
(defn- del-object-in-bulk
|
(defn- del-object-in-bulk
|
||||||
|
@ -189,7 +191,7 @@
|
||||||
(build)))
|
(build)))
|
||||||
ids)
|
ids)
|
||||||
delc (.. (Delete/builder)
|
delc (.. (Delete/builder)
|
||||||
(objects oids)
|
(objects ^Collection oids)
|
||||||
(build))
|
(build))
|
||||||
dor (.. (DeleteObjectsRequest/builder)
|
dor (.. (DeleteObjectsRequest/builder)
|
||||||
(bucket bucket)
|
(bucket bucket)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue