Skip to content

Instantly share code, notes, and snippets.

@samedhi
Last active May 10, 2018 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samedhi/39b08c05aa55c659e41ce21045072a58 to your computer and use it in GitHub Desktop.
Save samedhi/39b08c05aa55c659e41ce21045072a58 to your computer and use it in GitHub Desktop.
(ns inferno.storage
(:import
[com.google.cloud.storage BlobId]
[com.google.cloud.storage BlobInfo]
[com.google.cloud.storage StorageOptions]))
(set! *warn-on-reflection* true)
(defn storage [] (.getService (StorageOptions/getDefaultInstance)))
(def con (storage))
(defn upload! [^com.google.cloud.storage.Storage con bucket blob s]
(let [blobId (. BlobId (of bucket blob))
blobInfo (-> (BlobInfo/newBuilder blobId)
(.setContentType "text/plain")
(.build))
data (.getBytes s "UTF-8")
opts (into-array com.google.cloud.storage.Storage$BlobTargetOption [])]
(.create con blobInfo data opts)))
(upload! con "inferno-8d188.appspot.com" "hey.txt" "Hello World!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment