透過應用程式代理檔案。這有助於避免重新導向,並使快取檔案更為容易。
警告:預設情況下,所有 Active Storage 控制器都是公開可存取的。雖然產生的網址很難猜測,但卻是永久存在的。如果你的檔案需要較高的保護等級,請考慮實作 經過驗證的控制器。
方法
- S
包含的模組
執行個體公共方法
show() 連結
來源:show | 在 GitHub 上
# File activestorage/app/controllers/active_storage/blobs/proxy_controller.rb, line 14 def show if request.headers["Range"].present? send_blob_byte_range_data @blob, request.headers["Range"] else http_cache_forever public: true do response.headers["Accept-Ranges"] = "bytes" response.headers["Content-Length"] = @blob.byte_size.to_s send_blob_stream @blob, disposition: params[:disposition] end end end