Last active
May 10, 2018 21:02
-
-
Save samedhi/39b08c05aa55c659e41ce21045072a58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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