Skip to content

guivinicius/simple_google_drive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple interface for Google Drive API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages