I am creating an application that lets users store data in their personal dropbox in a protected folder that the application controls. So each user needs to store and access files in their own personal dropbox account.
To do this I'd like to leverage the paperclip-dropbox gem for storage. It allows paperclip to directly upload to dropbox: https://github.com/janko-m/paperclip-dropbox.
Here is the code that sets the authorization information for the paperclip-dropbox gem. NOTE: current_user does not work at the moment. I'm just putting that there to outline what would need to happen for the current setup to work.
Image.rb
has_attached_file :avatar,
:storage => :dropbox,
:dropbox_credentials => {app_key: DROPBOX_KEY,
app_secret: DROPBOX_SECRET,
access_token: current_user.token,
access_secret: current_user.secret,
user_id: current_user.uid,
access_type: "app_folder"}
Notice the dropbox authentication requires the current_user to get that particular set of credentials.
I know that the current_user is not supposed to be accessed from the model and I'd like to keep it that way so could anyone help me figure out how to do that with this current setup? Or suggest a better alternative?
Basically, I need to conditionally change the access_token, access_secret, & user_id on a per user basis.
Thanks!