views:

43

answers:

1

Is there a way to make paperclip attachments private? As in only where I explicitly want a user to be able to access a file, can the user access the file.

Obviously the file can't be in a public directory, but how do I get paperclip to check the user's access rights when trying to access that file to begin with?

+1  A: 

Hello,

PaperClip does not handle downloading the attachment. It only handles the uploading, processing and saving of the file.

If you need something like this, you must save the photo in a private folder (or in DB, if this suits your needs). Then, you can implement a controller/action that will verify the user's credentials, read the file and then send the file as binary content.

To send a binary content from the controller, you may want to check ActionController::Streaming API

You may also want to check this thread on SO.

Vlad Zloteanu
The only thing is, paperclip also allows for serving of those files, such a thing would have to be disabled.
Dmitriy Likhten
No. It's just that paperclips default setting for storing the files is in the applications public folder.
mikezter