在尝试上载JSON字符串并覆盖GCS bucket中的现有对象时,出现以下错误
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')
有人能帮我理解为什么会发生这个问题吗
以防9个月后有人需要。 您通常不希望使用两个不同的blob。很多时候,你必须在两个方向上进行多次读写。因此,我坚决反对使用这种方法。 您只需通过调用“reload()”显式刷新CRC32校验和即可:
要复制您遇到的错误,请执行以下操作:
您可能正在使用相同的blob来下载和上载内容。要防止此错误,您需要创建两个blob实例:
相关问题 更多 >
编程相关推荐