我一直在使用ruby sdk与FirebaseStorage
连接,它的工作正常,但是我需要知道如何增加该链接的有效期,它只提供1或2分钟的有效期。我正在用铲斗连接
project_id = "wearabe6a"
key_file = "service-account.json"
storage = Google::Cloud::Storage.new project: project_id, keyfile: key_file
bucket = storage.bucket "wearableeo.appspot.com"
file = bucket.file file_name
,然后我得到了签名的URL。哪一个可以在几分钟内正常工作,但是如何增加该链接的有效期?
file.signed_url
更新:
我一直在使用此gem进行云存储https://github.com/GoogleCloudPlatform/ruby-docs-samples/blob/master/storage/files.rb
答案 0 :(得分:0)
您可以在gem documentation for signed urls中找到可用参数的更多信息。
要将到期时间延长到5分钟(默认值)以上,请使用:
require "google/cloud/storage"
storage = Google::Cloud::Storage.new
bucket = storage.bucket "my-todo-app"
file = bucket.file "avatars/heidi/400x400.png"
# Expire in five hours.
# 18000 is five hours in seconds.
shared_url = file.signed_url expires: 18000