google-cloud-storage - @google-cloud/storage 使用 generateSignedPostPolicyV4 出错
问题描述
我正在关注这个例子: https ://github.com/googleapis/nodejs-storage/blob/master/samples/generateV4SignedPolicy.js
我唯一的改变是:
const bucketName = "gs://my-bucket.appspot.com/";
const filename = "test.jpg";
const { Storage } = require("@google-cloud/storage");
const storage = new Storage({
projectId: require("./key.json").project_id,
credentials: require("./key.json"),
});
然后我将输出导出到一个 HTML 文件来测试它:
node index.js > index.html
但是当我提交文件时,我收到:
<Error>
<Code>InvalidPolicyDocument</Code>
<Message>
The content of the form does not meet the conditions specified in the policy document.
</Message>
<Details>
Policy did not reference these fields: bucket submit
</Details>
</Error>
这是代码示例中的错误吗?
我需要任何配置/权限吗?
解决方案
我最后一次工作是在 5 月 11 日星期一。我认为他们更新了 API 以不自动将存储桶添加到字段列表中。修复很简单,只需在创建时将存储桶添加到字段列表中。
...
const options = {
expires,
fields: {
'x-goog-meta-test': 'data',
'bucket': 'my-bucket'
},
};
...
编辑:找到引用此重大更改的 PR。https://github.com/googleapis/conformance-tests/pull/31。不久之后,@google-cloud/storage 模块可能会更新。
推荐阅读
- python - 如何根据文件名组合/附加PDF?
- php - 即使为空,数组也充满了空白值
- mysql - eZ平台本地安装无法连接MySQL数据库
- amazon-s3 - Cloud Storage 客户访问最佳做法
- amazon-web-services - AWS 节点的 Docker 上是否有时间同步过程?
- python - pdoc 生成的 HTML 中的方法参数格式不正确
- go - 如何在 EC2 实例的 2 个端口上运行简单的 Go 服务器?
- ios - 多个命令在存档上产生 gRPCCertificates.bundle 错误(iOS Xcode 11.1,Firebase SDK)
- c# - 无法访问 C# 中 Activator 返回的对象方法
- swift - 如何在 Swift 中转换 @Binding