Skip to content

Commit

Permalink
change input stream type, bump version 0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ichramm committed Oct 26, 2023
1 parent 20e41f8 commit 6be957b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.intception/blob-storage "0.4.4"
(defproject com.intception/blob-storage "0.4.5"
:description "Blob Storage Library"
:url "https://github.com/intception/blob-storage"
:license {:name "Eclipse Public License"
Expand Down
17 changes: 8 additions & 9 deletions src/blob_storage/postgres/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,14 @@
stmt (j/prepare-statement conn
"SELECT * FROM blobs WHERE id = ?")
row (first (j/query db [stmt id]))]
(some-> row
(th/when-> (:oid row)
(assoc :blob (large-object->file conn (:oid row))))
(th/when-> (:oid row)
;; don't lose the reference to the file
(#(assoc % :file (:blob %))))
(clojure.core/update :blob #(io/input-stream %))
;; internal implementation detail, no need to expose it
(dissoc :oid)))))
(when row
(merge
(select-keys row [:id :size :created_at :updated_at :tag])
(if (:oid row)
(let [file (large-object->file conn (:oid row))]
{:file file
:blob (io/input-stream file)})
{:blob (java.io.ByteArrayInputStream. (:blob row))}))))))

(defn get-blob-metadata
"Retrieves blob metadata from database, nil if blob does not exists"
Expand Down

0 comments on commit 6be957b

Please sign in to comment.