通过应用程序代理文件。这避免了重定向,并使文件更容易缓存。
警告:默认情况下,所有 Active Storage 控制器都是公共可访问的。生成的 URL 难以猜测,但按设计是永久的。如果您的文件需要更高水平的保护,请考虑实现 身份验证控制器。
方法
- S
包含的模块
实例公共方法
show() 链接
来源: show | 在 GitHub 上
# File activestorage/app/controllers/active_storage/representations/proxy_controller.rb, line 13 def show http_cache_forever public: true do send_blob_stream @representation, disposition: params[:disposition] end end