0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -05:00

Avoid reflection on s3 storage backend.

This commit is contained in:
Andrey Antukh 2021-01-19 14:54:34 +01:00 committed by Alonso Torres
parent 34e5e5c513
commit ef25f8a721
2 changed files with 15 additions and 9 deletions

View file

@ -26,7 +26,10 @@
[cuerdas.core :as str]
[integrant.core :as ig]
[lambdaisland.uri :as u]
[promesa.exec :as px]))
[promesa.exec :as px])
(:import
java.io.InputStream))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Storage Module State
@ -159,8 +162,9 @@
;; if the source and destination backends are different, we just
;; need to obtain the streams and proceed full copy of the data
(with-open [input (-> (resolve-backend storage (:backend object))
(impl/get-object-data object))]
(with-open [^InputStream input
(-> (resolve-backend storage (:backend object))
(impl/get-object-data object))]
(-> (resolve-backend storage (:backend storage))
(impl/put-object object* (impl/content input (:size object))))))

View file

@ -24,6 +24,8 @@
java.io.InputStream
java.io.OutputStream
java.nio.file.Path
java.time.Duration
java.util.Collection
software.amazon.awssdk.core.sync.RequestBody
software.amazon.awssdk.regions.Region
software.amazon.awssdk.services.s3.S3Client
@ -105,7 +107,7 @@
;; --- HELPERS
(defn- lookup-region
(defn- ^Region lookup-region
[region]
(case region
:eu-central-1 Region/EU_CENTRAL_1))
@ -161,7 +163,7 @@
(bucket bucket)
(key (str prefix (impl/id->path id)))
(build))
obj (.getObject ^S3Client client gor)]
obj (.getObject ^S3Client client ^GetObjectRequest gor)]
(io/input-stream obj)))
(def default-max-age
@ -175,10 +177,10 @@
(key (str prefix (impl/id->path id)))
(build))
gopr (.. (GetObjectPresignRequest/builder)
(signatureDuration max-age)
(getObjectRequest gor)
(signatureDuration ^Duration max-age)
(getObjectRequest ^GetObjectRequest gor)
(build))
pgor (.presignGetObject ^S3Presigner presigner gopr)]
pgor (.presignGetObject ^S3Presigner presigner ^GetObjectPresignRequest gopr)]
(u/uri (str (.url ^PresignedGetObjectRequest pgor)))))
(defn- del-object-in-bulk
@ -189,7 +191,7 @@
(build)))
ids)
delc (.. (Delete/builder)
(objects oids)
(objects ^Collection oids)
(build))
dor (.. (DeleteObjectsRequest/builder)
(bucket bucket)