Liking cljdoc? Tell your friends :D

gstorage

cljdoc badge Clojars Project

gstorage is a small wrapper for Google Storage API.

Installation

Add the following dependency to your project.clj file:

[gstorage "0.1.3"]

Documentation

Documentation is available on cljdoc

Usage

This library provides two clients: local, which provides the basic set of features and aids local development and tests. All operations should behave like Google Storage, except permission and metadata.

The cloud client is the one that actually uses Google Storage APIs. To use it, one must first obtain Service Credentials, preferablly associated with a service account. More information can be found on Google Cloud Documentation.

To initialize a client, provide either the JSON contents of the obtained file, a File or Reader object, or the Path to the credentials file.

(ns hello-world.core
  (:require [clojure.java.io :as io]
            [gstorage.core :as gstorage]
            [gstorage.client :refer :all]))

(def credentials-path "/tmp/credentials.json")
(def client (gstorage/new-client :cloud credentials-path))

; Create a new Bucket
(def bucket (make-bucket client "my-bucket-name"))
; => Bucket{:name "my-bucket-name" ...}

; Upload an object
(put-object client bucket (io/file "/tmp/cats.jpg"))
; => BucketObject{:name "cats.jpg"}

Licence

MIT License

Copyright (c) 2020 - Victor Gama de Oliveira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close