Code Monkey home page Code Monkey logo

gcs-ruby's Introduction

gcs-ruby

Build Status

Groovenauts' wrapper library for Google Cloud Storage with google-api-ruby-client.

Installation

Add this line to your application's Gemfile:

gem 'gcs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gcs

Usage

gcs = Gcs.new(email_address, private_key)

# get bucket list
gcs.bucket(project_id)

# get object list
gcs.list_objects("myBucket", prefix: "path/to/subdir", max_results: 1000)

# get object metadata
get_object "myBucket", "myObject"
get_object "gs://myBucket/myObject"

# download object content
io = StringIO.new
get_object "myBucket", "myObject", download_dest: io
get_object "gs://myBucket/myObject", download_dest: io

# delete object
gcs.delete_object("myBucket", "myObject")
gcs.delete_object("gs://myBucket/myObject")

# create new object
io = StringIO.new("Hello, World!\")
gcs.insert_object("myBucket", "myObject", io)

# copy recursively
gcs.copy_tree("gs://myBucket1/src", "gs://myBucket2/dest")

# delete recursively
gcs.remove_tree("gs://myBucket/dir")

# read object content with size limitation
gcs.read_partial("gs://myBucket/myObject", limit: 1024) # => read first part of object at least 1024 bytes.
gcs.read_partial("myBucket", "myObjet", limit: 1024)
gcs.read_partial("gs://myBucket/myObject", limit: 1024, trim_after_last_delimiter: "\n") #=> remove substr after last "\n"

gcs-ruby's People

Contributors

minimum2scp avatar nagachika avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.