0.01
No commit activity in last 3 years
No release in over 3 years
This library can be used as a module for `fog` or as standalone provider to use Dropbox in applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

Fog::Dropbox

Fog's great! Let's support Dropbox.

Storage

Application Setup

You're going to need to setup a Dropbox Application.

  • Select Dropbox API App (not Drop-ins App).
  • Select Files and datastores
  • Select can be limited to its own folder (unless yours can't, but it probably can).

Click Generate Access Token to create an OAuth2 access token for your account. Grab this.

Installation

Add this line to your application's Gemfile:

gem 'fog-dropbox'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fog-dropbox

Usage

fog_client = Fog::Storage::Dropbox.new(:dropbox_oauth2_access_token => ENV['DROPBOX_OAUTH2_ACCESS_TOKEN'])

# Read directory
folder = "/folder"
filename = "file"
key = [folder, filename].join('/')
directory = fog_client.directories.get(folder)
puts directory.inspect

# Read file
file = directory.files.get(key)
puts file.inspect
puts file.body

# Get file share link
puts file.url()

# Write string
file.body = "New Content"
file.save()

# Write large file
large_file = Tempfile.new("fog-dropbox-multipart")
6.times { large_file.write("x" * (1024**2)) } # 6 MB file
large_file.rewind
file.body = large_file
file.save()

# Delete
file.destroy()

Contributing

  1. Fork it ( https://github.com/zshannon/fog-dropbox/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 a new Pull Request