This is a simple question but I can't seem to find an answer for it anywhere. If you store some files (say some static PDFs) in your public
directory, is there a way that someone who isn't authorized to view those files, can view them by typing in a url like example.com/public/static_document.pdf
? If so, can you disable this in Rails?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The public is definitely public and open to people guessing the URL.
Check out Ruby On Rails - Securing Downloads Area for someone else asking similar.
I store these generally in Rails.root/secure_files and then use send_file in the Controller to authorize and send these files.
回答2:
The public folder contains the static files and compiled assets for the client to read. The folder by default is accessible to anyone visiting your site. Test it by typing in a slug of the folder name currently in your public folder.