开发者

paperclip private files

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 t开发者_JAVA技巧he 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜