相关疑难解决方法(0)

通过签名网址将文件PUT到Google云端存储(GCS)

我正在尝试使用"已签名的网址"来访问/上传文件到Google云端存储(GCS).

按照https://developers.google.com/storage/docs/accesscontrol#Signing-Strings中的说明操作

我做了什么:

  • 在Google Cloud Console上注册了"Web应用程序".
  • 使用已注册的Web应用程序屏幕的"证书"部分中的"生成新密钥"生成新的私钥.
  • 创建了要签名的字符串,并使用页面"如何签名"部分提供的示例代码对其进行签名(只需对Java主程序的硬编码值进行微调).更新:为GcsSigner.java创建了一个要点.
  • 确保已签名的字符串是URL编码的.
  • 指定的HTTP标头:x-goog-api-version,x-goog-project-id,Content-Type.
  • 指定的网址参数:GoogleAccessId,签名,过期.
  • 使用Postman(Chrome扩展程序)来模拟PUT请求.

但是,我仍然得到这个(状态:403 Forbidden):

<?xml version='1.0' encoding='UTF-8'?>
<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

text/plain
1384084959392
x-goog-api-version:2
x-goog-project-id:99999
/mybucket/myfile.txt</StringToSign>
</Error>
Run Code Online (Sandbox Code Playgroud)

即使我根据"StringToSign"中的值对字符串进行重试,我仍然会得到相同的错误.

在这里阅读各种相关的帖子,但找不到任何解决方案,其中大部分是指x-goog-api-version:1我在使用版本2时.

我错过了什么?任何帮助将不胜感激.

java google-cloud-storage

12
推荐指数
2
解决办法
6226
查看次数

标签 统计

google-cloud-storage ×1

java ×1