How to store private pictures and videos in Ruby on Rails

后端 未结 4 813
情歌与酒
情歌与酒 2020-12-03 06:05

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
4条回答
  •  忘掉有多难
    2020-12-03 06:40

    If you want to host files yourself, you can perform authentication at the controller level as has been suggested. One of my applications has an AssetController that handles serving of files from the 'private' directory, for example.

    One thing I wanted to add is that you should review this guide for setting up X-Sendfile, which will let your application tell the web server to handle actually sending the files. You'll see much better performance with this approach.

提交回复
热议问题