Here s a story:
- User A should be able to upload an image.
- User A should be able to set a privacy. ("Public" or "Private").
- User B should not be able to access "Private" images of User A.
I m planning to user Paperclip for dealing with uploads.
If I store the images under "RAILS_ROOT/public/images", anyone who could guess the name of the files might access the files. (e.g., accessing http://example.com/public/images/uploads/john/family.png )
I need to show the images using img
tags, so I cannot place a file except public
.
How can I ensure that images of a user or group is not accessible by others?
(If I cannot achieve this with Paperclip, what is a good solution?)