【发布时间】:2018-07-22 03:55:27
【问题描述】:
我疯了。
我将 Shrine (https://github.com/janko-m/shrine) 与 Google Cloud Storage (https://github.com/renchap/shrine-google_cloud_storage) 一起使用,但是当我启动 PUT 通话时,我得到了这个:
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.
</Message>
<StringToSign>
PUT
image/jpeg
1518399402
/mybucket.appspot.com/7d5e4aad1e3a737fb8d2c59571fdb980.jpg
</StringToSign>
</Error>
我为 presign_endpoint 关注了此信息 (http://shrinerb.com/rdoc/classes/Shrine/Plugins/PresignEndpoint.html),但仍然没有:
class FileUploader < Shrine
plugin :presign_endpoint, presign_options: -> (request) do
filename = request.params["filename"]
extension = File.extname(filename)
content_type = Rack::Mime.mime_type(extension)
{
content_type: content_type
}
end
end
我试过有没有这个(每次都重新启动 Rails 服务器)。
我哪里错了?
我还尝试使用 Postman 对那个 URL 进行 PUT 并且没有任何 content-type。但还是什么都没有。
我在这里阅读:https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1976 和这里:https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1695
如何在没有 Rails 的情况下尝试?
是否有 REPL(或类似的)可以尝试使用我的凭据和文件?
【问题讨论】:
标签: ruby file-upload google-cloud-storage pre-signed-url shrine