- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在尝试上传 JSON 字符串并覆盖 GCS 存储桶中的现有对象时,出现以下错误。
google.api_core.exceptions.BadRequest: 400 POST https://storage.googleapis.com/upload/storage/v1/b/cc-freshdesk/o?uploadType=multipart: {
"error": {
"code": 400,
"message": "Provided CRC32C \"i8Z/Pw==\" doesn't match calculated CRC32C \"mVn0oQ==\".",
"errors": [
{
"message": "Provided CRC32C \"i8Z/Pw==\" doesn't match calculated CRC32C \"mVn0oQ==\".",
"domain": "global",
"reason": "invalid"
},
{
"message": "Provided MD5 hash \"6NMASNWhbd4WlIj/tWK4Sw==\" doesn't match calculated MD5 hash \"9H5THzsUBARmhzw5NjjgNw==\".",
"domain": "global",
"reason": "invalid"
}
]
}
}
: ('Request failed with status code', 400, 'Expected one of', <HTTPStatus.OK: 200>)
找到下面的代码片段:
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
config_blob = bucket.blob(destination_blob_name)
config_blob.upload_from_string(json.dumps(config_data,indent=4), content_type='text/plain')
任何人都可以帮助我理解为什么会发生这个问题。
最佳答案
要复制您遇到的错误:
import json
from google.cloud import storage
client = storage.Client()
bucket = client.get_bucket('some-bucket')
# blob1 object
blob1 = bucket.get_blob('file.json')
# downloads content
blob1_string = blob1.download_as_string()
# converts to dict and update content
blob1_obj = json.loads(blob1_string)
blob1_obj['some-key'] = 'some value'
# upload using same blob instance
blob1.upload_from_string(json.dumps(blob1_obj))
# throws error like this `Provided MD5 hash "Ax9olGoqOSb7Nay2LNkCSQ==\" #doesn't match calculated MD5 hash \"XCMPR0o7NdgmI5zN1fMm6Q==\".",
您可能正在使用同一个 blob 来下载和上传内容。为防止出现此错误,您需要创建两个 blob 实例:
import json
from google.cloud import storage
client = storage.Client()
bucket = client.get_bucket("some-bucket")
# blob1 object -- for downloading contents
blob1 = bucket.get_blob('file.json')
blob1_string = blob1.download_as_string()
# Convert to dictionary
blob1_obj = json.loads(blob1_string)
# Add stuff
blob1_obj['some-key'] = 'some value'
# blob2 object -- for uploading contents
blob2 = bucket.get_blob('file.json')
blob2.upload_from_string(json.dumps(blob1_obj))
# no error
关于python - 谷歌云存储 : Mismatch in CRC32C & MD5 while upload string to GCS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63823624/
GCS Transfer Service是定期传输数据的一个很好的解决方案。将一个存储桶同步到另一个存储桶(目标存储桶具有存档存储类)的适当设置是什么? 我担心的一个问题是,如果服务正在检查相同的对象
我正在尝试使用 Envoy 代理将请求路由到 GCS。我能够通过代理路由实际的存储请求。但是当我在 GCS 连接器设置中设置此 fs.gs.proxy.address 参数时,OAuth token
这个问题在这里已经有了答案: Is it necessary to recreate a Google Container Engine cluster to modify API permissi
GCS = 谷歌云存储 GAE = 谷歌应用引擎 如果给定目录(模拟目录,因为不存在真实目录)中有大量文件,我该如何管理: 在我的 GAE Python 代码中列出用于某些处理的所有文件? 按文件名降
GCS 文件 API 已于 2015 年 7 月 28 日关闭。在我的开发服务器中,我收到以下警告: The Google Cloud Storage Java API is deprecated a
我想将 400MB 的文件上传到 Google Cloud Storage。以下是我用来获取上传网址并在 angularjs 中发布的代码片段 Java Servlet: UploadOptions
一个简单的 Python 代码,用于列出 Google Cloud Storage 中特定文件夹中的对象: from apiclient import discovery import apiclie
管理Terraform状态文件的最佳方式是通过云端的统一的存储,如谷歌云就用GCS。 首先要创建一个Bucket:
我目前正在尝试编写一些代码以将 Google 存储桶中的一些“区域”对象转换为“冷线”,但出现以下异常: {The service storage has thrown an exception: G
我需要从 GCS 存储桶中的文件夹中删除数百万个对象。 这是我目前的实现。 bucket = self.storage_client.bucket(bucket_name) blobs = bucke
我已经安装了 hadoop 3 版本的 GCS 连接器,并将以下配置添加到 core-site.xml,如 Install.md 中所述.目的是将数据从本地集群中的 hdfs 迁移到云存储。 核心站点
我正在尝试使用 Java 存储客户端从远程服务器读取文件行数。 还尝试了 gsutil cat gs://{bucket_name}/file.txt | wc -l < 还有其他办法吗? 最佳答
我从开始 client = storage.Client() bucket = client.get_bucket(BUCKET_NAME) 我知道如何: 列出 bucket
如果有任何文件上传到 Google 云存储,我们将通过 Google 云功能自动处理文件。我们使用 python 编写了代码。 https://cloud.google.com/functions/d
关注谷歌的 Getting Started我使用以下代码获取远程目录中所有文件的列表 class GCSFileStorage { String bucket = "bucket_name";
我想获取存储在 Google Cloud Storage 中的文件的文件元数据。实际上,我们需要文件的媒体链接,以便可以下载文件或将 URL 添加到下载页面。 Blob blob = storage.
我使用 scala 开发应用程序,通过 hdfs 上的服务帐户凭据从 GCS 下载加密文件(使用客户提供的加密 key 的加密文件) val path = new Path(keyfile) val
当我通过 Console 从 bucket 中的“文件夹”中删除所有文件时,该文件夹也消失了,因为没有目录这样的东西 - 整个bucket 之后的路径是关键。 但是,当我通过 REST API 以编程
我现在觉得有点傻。我一直在阅读大量文档和 stackoverflow 问题,但我无法正确理解。 我在 Google Cloud Storage 上有一个文件。它在桶“test_bucket”中。在这个
我正在使用在 Google 计算引擎上运行的 node.js 应用程序为每个用户创建 GCS 存储桶。存储桶创建是每个用户的一次性事件。但是当我尝试运行该程序为 20 个用户并行创建唯一的存储桶时,出
我是一名优秀的程序员,十分优秀!