Friday, 19 July 2013

Integrate Dropbox with your Rails App by using Dropbox API gem with Paperclip

We are going to steal all the Dropbox documents by using Dropbox API with the help of Paperclip. Hey got scared !! .. Oh pls ..  just kidding. But seriously ,We can do that with the help of dropbox-api gem & paperclip .

Step 1

Create an App in Dropbox  Developer  to get the key-Secret pair. You have to set the permission type to "Full Dropbox" mode to get the full Read/Write Access to any file inside the user's Dropbox.

Step 2

Setup your Rails App , include these 2 gems in your Gemfile.

gem 'dropbox-api'
gem "paperclip"

Step 3

Create a file in your config/initializers directory and name it dropbox.rb and put the following line of code inside.

Dropbox::API::Config.app_key    = 'APP KEY'
Dropbox::API::Config.app_secret = 'SECRET KEY'
Dropbox::API::Config.mode       = "dropbox"