当我试图通过开发服务器上传时,Google云存储客户端库将返回500错误。
ServerError: Expect status [200] from Google Storage. But got status 500.
我没有对项目进行任何更改,而且代码在生产中仍然正常工作。
我尝试gcloud components update
获得最新的dev_server,并更新到最新的Google云存储客户端库。
我再次运行gcloud init
,以确保已加载凭据,并确保使用了正确的桶。
该项目正在windows 10. Python版本2.7上运行。
知道为什么会这样吗?
谢谢
发布于 2019-07-18 11:01:17
原来这是个问题已经有一段时间了。这与with存储文件名的生成方式有关。https://issuetracker.google.com/issues/35900575
修复方法是对这个文件进行猴子加密: google-cloud-sdk\platform\google_appengine\google\appengine\api\blobstore\file_blob_storage.py
def _FileForBlob(self, blob_key):
"""Calculate full filename to store blob contents in.
This method does not check to see if the file actually exists.
Args:
blob_key: Blob key of blob to calculate file for.
Returns:
Complete path for file used for storing blob.
"""
blob_key = self._BlobKey(blob_key)
# Remove bad characters.
import re
blob_fname = re.sub(r"[^\w\./\\]", "_", str(blob_key))
# Make sure it's a relative directory.
if blob_fname and blob_fname[0] in "/\\":
blob_fname = blob_fname[1:]
return os.path.join(self._DirectoryForBlob(blob_key), blob_fname)
https://stackoverflow.com/questions/57100699
复制相似问题