ROR HEROKU Working with file storage like paperclip in heroku for free of cost ( paperclip and dropbox) paperclip-dropbox config | ROR, HEROKU, file storage, paperclip, in heroku, free of cost, paperclip, dropbox, paperclip-dropbox config
In my project i am using paper-clip and deployed to heroku, heroku not allows the file storage but to use aws normally, i don’t want to spend money so i can use drop box storage which will gives 2gb free storage space.
So i am using paper-clip with drop box with library papercklip-dropbox gem, steps to follow are given below.
- Include gem “paperclip-dropbox” in your gem file
- Run the command $bundel install
- Create drop box api app in https://www.dropbox.com/developers/apps and give read write permissions it gives you the App key and App secret which will used in further configeration
- Generate the other required details using available details, run the rake task to generate other details “$rake dropbox:authorize APP_KEY=your_app_key APP_SECRET=your_app_secret ACCESS_TYPE=your_access_typ “, this command will generate the access_token, access_token_secret, user_id
- Create dropbox_config.yml file in config folder and place all keys got in previous steps
app_key: YOUR_APP_KEY
app_secret: YOUR_APP_SECRET
access_token: YOUR_ACCESS_TOKEN
access_token_secret: YOUR_ACCESS_TOKEN_SECRET
user_id: YOUR_USER_ID
access_type: “app_folder” - Now relace paper clip code with new code for attachment, like User profile picture
#added for paperclip-dropbox gem
has_attached_file :picture,
:storage => :dropbox,
:dropbox_credentials => “#{Rails.root}/config/dropbox_c
onfig.yml”,
:styles => { :medium => “300×300” , :thumb => “100×100>”},
:dropbox_options => {
:path => proc { |style| “#{Rails.env}/#{style}/#{id}_#{picture.original_filename}”}, :unique_filename => true
} - Deploy your code in heroku you can, you can see all files or images uploaded as profile pictures will store in your drop box.
Enjoy the drop box free usage in cloud
Comments
Post a Comment