Dropbox SDK for Ruby
This is a small Ruby library for accessing the new Dropbox API. It provides a single class, Dropbox::Client
, with methods that map to most of the Dropbox API endpoints. Currently all of the endpoints in the auth
, files
, and users
namespaces are supported. Sharing methods are planned.
Requirements
- Ruby 2.1.0 or later
- The http gem
Installation
Run:
gem install dropbox-sdk-v2
Then, in your source files:
require 'dropbox'
Or just add this to your Gemfile:
gem 'dropbox-sdk-v2'
Usage
Also see the full YARD documentation.
Set up a client:
require 'dropbox'
dbx = Dropbox::Client.new(ENV['DROPBOX_ACCESS_TOKEN'])
Create a folder:
folder = dbx.create_folder('/myfolder')
folder.id
folder.name
folder.path_lower
Upload a file:
file = dbx.upload('/myfolder/file.txt', 'file body')
file.size
file.rev
Download a file:
file, body = dbx.download('/myfolder/file.txt')
body.to_s
Delete a file:
dbx.delete('/myfolder/file.txt')
Contributing
All contributions are welcome. Please file an issue or submit a pull request.
This project strives for full test coverage. To run the test suite, make a Dropbox App with "app folder" access and generate an access token. Then run DROPBOX_SDK_ACCESS_TOKEN="..." rake test
.