如何在Ruby on Rails中存储私人照片和视频 [英] How to store private pictures and videos in Ruby on Rails
问题描述
我打算使用回形针处理上传。
如果将图像存储在RAILS_ROOT / public / images下,任何能够猜出文件名称的人都可以访问这些文件。 (例如,访问 http://example.com/public/images/uploads/john /family.png )
我需要使用 img
标签显示图片,所以我不能放置除公共
以外的文件。
如何确保用户或组的图像不能被他人访问?
(如果我不能用Paperclip来实现这个功能,有什么好的解决方法?)
我会在后端使用Paperclip S3,将上传的文件设置为私有,然后使用查询字符串请求身份验证替代来为我的图像标记生成URL。
http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTAuthentication.html
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?)
I would have Paperclip use S3 on the back-end, set uploaded files to private, and then use "Query String Request Authentication Alternative" to generate the URLs for my image tags.
http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTAuthentication.html
这篇关于如何在Ruby on Rails中存储私人照片和视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!