upload - Google Cloud Storage Signed URL PUT Content-MD5
问题描述
I'm trying to create GCS signed URLs: https://cloud.google.com/storage/docs/access-control/create-signed-urls-program#signing-language
I want to have my clients upload directly to GCS. However, I'm running into the classic SignatureDoesNotMatch
error. I think it might be something to do with the Content-MD5 digest.
I have a question about the documentation. In 2b, it says you can add an MD5 digest. In the example below that, it looks like the digest might be base64 encoded or something, but the instructions say nothing about encoding the digest. Anyone have any experience with this?
edit: in my latest run, I stopped using MD5 digests, and everything worked fine.
解决方案
你猜对了,MD5 摘要必须是base64 编码的。
当您使用 MD5 摘要创建签名 URL 时,您的PUT
请求必须包含标头(如此处Content-MD5
指定)。
引用标准:
Content-MD5 = "Content-MD5" ":" md5-digest
md5-digest = <base64 of 128 bit MD5 digest as per RFC 1864>
MD5 摘要是根据实体主体的内容计算的,包括已应用的任何内容编码,但不包括应用于消息主体的任何传输编码。
进入签名的 MD5 摘要是md5-digest
上面的(因此是 base64)。
此外,这仅适用于PUT
对象上传(不适用于POST
或可恢复上传)。如上所述,在使用内容编码 ( Content-Encoding: gzip
) 时应小心。
推荐阅读
- swift - Swift:如何对返回函数的函数进行单元测试?
- python - 如何在不与python复制的情况下将数据插入mysql表?
- docker - 加速 docker healthcheck 容器
- mysql - 使用 Sequelize 的递归关系
- javascript - 单击设置日期时出现角度问题
- java - 如何使用 Spock 测试 Java 类?
- docker - 创建新的 Docker 映像时 VueJS 项目未更新
- algorithm - 我们如何将递归算法的外部复杂度与每次调用的复杂度结合起来?
- android - How do I deploy flutter app on mobile device for testing without using play store
- python - 视频文件的唯一标识符