与云服务相同的方式提供使用磁盘服务存储的文件。这意味着使用过期的、签名的 URL,这些 URL 仅用于即时访问,而非永久链接。请务必通过 BlobsController 或您自己的身份验证控制器进行访问,而不是直接访问服务 URL。
方法
实例公共方法
show() 链接
来源: show | 在 GitHub 上
# File activestorage/app/controllers/active_storage/disk_controller.rb, line 12 def show if key = decode_verified_key serve_file named_disk_service(key[:service_name]).path_for(key[:key]), content_type: key[:content_type], disposition: key[:disposition] else head :not_found end rescue Errno::ENOENT head :not_found end
update() 链接
来源: show | 在 GitHub 上
# File activestorage/app/controllers/active_storage/disk_controller.rb, line 22 def update if token = decode_verified_token if acceptable_content?(token) named_disk_service(token[:service_name]).upload token[:key], request.body, checksum: token[:checksum] head :no_content else head ActionDispatch::Constants::UNPROCESSABLE_CONTENT end else head :not_found end rescue ActiveStorage::IntegrityError head ActionDispatch::Constants::UNPROCESSABLE_CONTENT end