开发者

How to Serve Files from Outside Public Directory?

Whenever I try to serve content (via send_file or as the src of an iframe) from a directory outside of 'public' via the asset's relative or absolute path I get an error stating either the asset could not be found or 'c' (as in C:) is not a valid protocol. Does anyone know why I'm fa开发者_高级运维cing these problems and how to solve them without using symlink?

Thanks.


This is just a guess, as I don't use Windows for anything other than browser testing.

Instead of creating the string for the file path (e.g. send_file "C:\sites\this_one\secure_files\here.pdf") use the File class to build the path (e.g. send_file File.join(Rails.root, 'secure_files', 'here.pdf')).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜