https://github.com/robin850/carrierwave-dropbox
Carrierwave storage for Dropbox
https://github.com/robin850/carrierwave-dropbox
carrierwave carrierwave-storage dropbox storage
Last synced: about 1 year ago
JSON representation
Carrierwave storage for Dropbox
- Host: GitHub
- URL: https://github.com/robin850/carrierwave-dropbox
- Owner: robin850
- License: mit
- Created: 2013-08-02T13:12:07.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2018-05-27T17:10:27.000Z (about 8 years ago)
- Last Synced: 2025-04-17T08:44:53.123Z (about 1 year ago)
- Topics: carrierwave, carrierwave-storage, dropbox, storage
- Language: Ruby
- Size: 90.8 KB
- Stars: 66
- Watchers: 5
- Forks: 28
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Carrierwave uploads on Dropbox
This gem allows you to easily upload your medias on Dropbox using the awesome
[CarrierWave](https://github.com/carrierwaveuploader/carrierwave) gem.
## Installation
First, you have to create a [Dropbox app](https://www.dropbox.com/developers/apps).
You can either create a "full dropbox" or "app folder" application. Please see
[this wiki](https://github.com/janko-m/paperclip-dropbox/wiki/Access-types) for
further information and gotchas.
Then, add this line to your application's Gemfile:
~~~ruby
gem 'carrierwave-dropbox'
~~~
Then run `bundle` to install the gem.
To make a Dropbox app and generate a token, go [here](https://www.dropbox.com/developers/apps).
Then, specify the token in your configuration (in an initializer for instance)
like this:
~~~ruby
CarrierWave.configure do |config|
config.dropbox_access_token = Rails.application.dropbox_access_token
end
~~~
**Note**: It's advisable not to directly store the credentials in your files
especially if you are using a SCM (e.g. Git). You should rather rely on Rails'
`secrets` feature.
Then you can either specify in your uploader files the storage or define it
globally through `CarrierWave.configure`:
~~~ruby
class ImageUploader < CarrierWave::Uploader::Base
storage :dropbox
end
~~~
## Notable differences from other storage engines
Unlike typical CarrierWave storage engines, we do not assume an uploaded file
will always be at the same path, as Dropbox UI users may move files around. As
such, this gem relies on the file id. There are two significant implications to
this approach:
1. The `#store_path` and `#store_dir` methods are not guaranteed to be accurate
after the initial file upload. We do not overwrite these methods as the end user
will often overwrite these methods to specify where the file should initially
be stored.
2. The default `#filename` method is not accurate, as we are storing the Dropbox
id, rather than the name of the file. It's recommended that end users overwrite
the `#filename` method to delegate to the `CarrierWave::Storage::Dropbox::File`
interface. For example:
~~~ruby
class MyUploader < CarrierWave::Uploader::Base
storage :dropbox
def filename
if original_filename
# Perform any file name manipulation on initial upload
elsif file
file.filename
end
end
end
~~~
## Special thanks
This project is highly based on these two gems:
* [paperclip-dropbox](https://github.com/janko-m/paperclip-dropbox)
* [carrierwave-aws](https://github.com/sorentwo/carrierwave-aws)
Thanks to their respective authors and contributors!
## Contributing
1. Fork it
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
## License
Please see the `LICENSE` file for further information.