以與雲端服務相同的方式提供儲存在磁碟服務中的檔案。這表示以到期、簽署的 URL,這類 URL 專用於立即存取,而非永久連結。請永遠透過 Blob 控制器或您自己已驗證的控制器,而不是直接連接到服務 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 :unprocessable_entity end else head :not_found end rescue ActiveStorage::IntegrityError head :unprocessable_entity end