A simple interface for Google Drive API
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
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
Each method name was made to be compliant with Google Drive API reference.
https://developers.google.com/drive/v2/reference/
client.about
# => {"kind": "drive#about", ... }
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)
- FILES_UPLOAD (https://developers.google.com/drive/manage-uploads)
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)
- FILES_UNTRASH (https://developers.google.com/drive/v2/reference/files/untrash)
client.files_untrash(file_id)
client.files_watch(file_id)
- Implement authenticantion flow
- Implementing more methods
- Improve test suite
- Fork it ( http://github.com/guivinicius/simple_google_drive/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request