Git Product home page Git Product logo

simple_google_drive's Introduction

SimpleGoogleDrive

Build Status Code Climate Bitdeli Badge

A simple interface for Google Drive API

Installation

Add this line to your application's Gemfile:

gem 'simple_google_drive'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple_google_drive

Getting Started

You need to create a new object and then call its methods. Simple like that.

 oauth2_access_token = "YOUR ACCESS TOKEN"
 client = SimpleGoogleDrive.new(oauth2_access_token)
 client.about

Methods

Each method name was made to be compliant with Google Drive API reference.

https://developers.google.com/drive/v2/reference/

About

    client.about
    # => {"kind": "drive#about", ... }

Files methods

 optional_params = {:updateViewedDate => true}
 client.files_get(file_id, optional_params)

This method is only for metadata-only requests not to upload files.

 body = {:title => "A thesis about how awesome I am", :description => "No need!", }
 optional_params = { :convert => true, :ocr => true }
 client.files_insert(body, optional_params)

Supporting only: simple and multipart uploads for now.

Simple Upload Example

 file_object = File.open("/tmp/awesome.pdf")
 args = {:uploadType => 'media'}
 client.files_upload(file_object, args)

Multipart Upload Example

 file_object = File.open("/tmp/awesome.pdf")
 args = {:uploadType => 'multipart', :body_object => {:title => "A thesis about how awesome I am", :description => "Ok! It needs!" }}
 client.files_upload(file_object, args)
 body = {:title => "A thesis about how awesome I am", :description => "Ok! It needs!" }
 optional_params = { :convert => true, :ocr => true }
 client.files_patch(file_id, body, optional_params)
 body = {:title => "A thesis about how awesome I am (copy)", :description => "Ok! It needs!" }
 optional_params = { :convert => true, :ocr => true }
 client.files_copy(file_id, body, optional_params)
 client.files_delete(file_id)

The most important part of this method is the search parameters and you can find more at https://developers.google.com/drive/search-parameters

 optional_params = {:maxResults => 10, :q => "title = 'awesome'"}
 client.files_list(optional_params)
 client.files_touch(file_id)
 client.files_trash(file_id)
 client.files_untrash(file_id)
 client.files_watch(file_id)

Todo's

  • Implement authenticantion flow
  • Implementing more methods
  • Improve test suite

Contributing

  1. Fork it ( http://github.com/guivinicius/simple_google_drive/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

simple_google_drive's People

Contributors

captn3m0 avatar guivinicius avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

captn3m0

simple_google_drive's Issues

OAuth Access Key

What does this refer to? I'm using a Google Drive Service account and I was given:

  1. Client ID
  2. Email address
  3. Public key fingerprint

Where do I get the access key?

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.