Google Cloud Storage - 开发服务器上的 PUT 失败

Google Cloud Storage - PUT Fails on Development Server

提问人:speedplane 提问时间:8/8/2015 最后编辑:Peter Mortensenspeedplane 更新时间:10/30/2023 访问量:848

问:

在我的开发服务器上,Google Cloud Storage 在执行命令时无法保存文件。PUT

同样的命令在生产中工作正常。响应标头(见下文)几乎没有调试信息。我的硬盘上有足够的空间,并且我一直以管理员身份运行开发服务器,因此它应该具有所有必要的权限。

有什么想法吗?

以下是相关的 Traceback(我更改了存储桶名称):

INFO     2015-08-07 14:14:41,415 module.py:809] default: "PUT /_ah/gcs/bucket/IPR2013-00219%2C%20No.%2016%20Institution%20Decision%20-%20Decis_2015-08-07%2018-14-25.100000.pdf?upload_id=encoded_gs_file%3AZG9ja2V0YWxhcm0tZGV2L0lQUjIwMTMtMDAyMTksIE5vLiAxNiBJbnN0aXR1dGlvbiBEZWNpc2lvbiAtIERlY2lzXzIwMTUtMDgtMDcgMTgtMTQtMjUuMTAwMDAwLnBkZg%3D%3D HTTP/1.1" 500 -
Traceback (most recent call last):
  File "Project\libs\cloudstorage\storage_api.py", line 794, in __exit__
    self.close()
  File "Project\libs\cloudstorage\storage_api.py", line 787, in close
    self._flush(finish=True)
  File "Project\libs\cloudstorage\storage_api.py", line 841, in _flush
    self._send_data(data, self._written, file_len)
  File "Project\libs\cloudstorage\storage_api.py", line 874, in _send_data
    {'upload_path': self._path_with_token})
  File "Project\libs\cloudstorage\errors.py", line 141, in check_status
    raise ServerError(msg)
ServerError: Expect status [200] from Google Storage. But got status 500.
Path: '/bucket/IPR2013-00219%2C%20No.%2016%20Institution%20Decision%20-%20Decis_2015-08-07%2018-14-25.100000.pdf'.
Request headers: {'accept-encoding': 'gzip, *', 'content-range': 'bytes 0-195060/195061', 'x-goog-api-version': '2'}.
Response headers: {'date': 'Fri, 07 Aug 2015 18:14:41 GMT', 'transfer-encoding': 'chunked', 'server': 'Development/2.0'}.
Body: ''.
Extra info: {'upload_path': '/bucket/IPR2013-00219%2C%20No.%2016%20Institution%20Decision%20-%20Decis_2015-08-07%2018-14-25.100000.pdf?upload_id=encoded_gs_file%3AZG9ja2V0YWxhcm0tZGV2L0lQUjIw
MTMtMDAyMTksIE5vLiAxNiBJbnN0aXR1dGlvbiBEZWNpc2lvbiAtIERlY2lzXzIwMTUtMDgtMDcgMTgtMTQtMjUuMTAwMDAwLnBkZg%3D%3D'}.

更新 2020仅供参考,我在这里向谷歌提出了这个问题,他们说他们不会修复它,因为它已经修复了,即使它显然没有。

更新 2022还是坏了!请参阅 Google 问题中建议的补丁程序。

蟒蛇 平台谷歌 云存储

评论

1赞 Scotty 12/1/2015
我收到同样的错误。尝试将 App Engine 升级到 1.9.30(从 1.9.25 左右)并将 python 库 GoogleAppEngineCloudStorageClient(升级到 1.9.22)。没有运气。想知道这是否可能与此有关:code.google.com/p/googleappengine/issues/detail?id=10996。FWIW,storage 命令在已部署的服务器上起作用,但不在开发服务器上起作用。
0赞 speedplane 7/8/2016
我调试了这个问题,这确实是 SDK 的错误。请参见 code.google.com/p/googleappengine/issues/detail?id=12976。在该问题报告中,我概述了一种可以对 SDK 进行猴子修补以使其正常工作的方法。请为该问题请求加注星标,以便引起 Google 的注意。
1赞 Memristor 5/2/2023
只是想给你一些想法:安全权限?服务器配置错误?服务器容量?哪些依赖项是您在开发人员中没有的?也尝试使用较小的文件。
0赞 Brandon Wegner 5/17/2023
您是否将其添加到代码中?import os import mock import google.auth.credentials os.environ[“DATASTORE_DATASET”] = “test” os.environ[“DATASTORE_EMULATOR_HOST”] = “127.0.0.1:8001” os.environ[“DATASTORE_EMULATOR_HOST_PATH”] = “127.0.0.1:8001/datastore” os.environ[“DATASTORE_HOST”] = “127.0.0.1:8001” os.environ[“DATASTORE_PROJECT_ID”] = “test” credentials = mock.模拟(spec=google.auth.credentials.Credentials) db = ndb。客户端(project=“test”, credentials=credentials)
0赞 Steve Barnes 6/15/2023
我发现令人担忧的是,目标路径包括编码为的空格(不是一个绝妙的主意)和编码为的逗号几乎从来都不是一个好主意)。开发服务器可能没有清理这些内容。%20%2C

答:

0赞 Syed Shafiyullah 8/25/2023 #1

确保您具有访问存储桶的正确权限。您可以通过运行以下命令来检查这一点:

gsutil ls -l gs://bucket/

如果您没有正确的权限,则需要联系您的 Google Cloud Storage 管理员,以授予您必要的权限。

此外,请确保存储桶存在。您可以通过运行以下命令来检查这一点:

gsutil ls gs://bucket/

确保您使用的是正确的 API 版本。开发服务器可能不支持您正在使用的 API 版本。

-2赞 Suresh Dooly 10/27/2023 #2

下面是一些步骤和注意事项,可帮助您排查并可能解决此问题:

网络和防火墙设置:确保您的开发服务器具有与 Google Cloud Storage 通信所需的网络连接。检查防火墙设置,确保没有可能阻止连接的限制。

凭据:确认您在开发服务器上使用了正确的 Google Cloud Storage 凭据和访问权限。确保您的凭据已正确配置,并具有执行 PUT 操作所需的访问权限。

库和 SDK 版本:请确保您使用的是适用于开发环境的正确且最新版本的 Google Cloud Storage 客户端库或 SDK。过时或不兼容的库可能会导致问题。

存储分区配置:仔细检查您尝试访问的 Google Cloud Storage 存储分区的配置。确保它设置正确,并且存储桶名称与您在代码中使用的名称匹配。

Error Handling: Consider implementing robust error handling and logging in your code to capture detailed error messages when such issues occur. This can help you gather more information about the problem.

Issue with Google: As you mentioned, you raised the issue with Google, and it seems like they were unresponsive or unhelpful. You might consider following up with them, providing detailed information about your issue, and asking for further assistance or clarification.

Check for Updates: Ensure that you are using the latest version of the library or SDK you are using. Sometimes, updates may address known issues.

Development Environment: Consider setting up a similar development environment as your production environment to replicate the issue more accurately and identify any environment-specific problems.

Community and Forums: Seek help from developer communities and forums related to Google Cloud Storage. Other developers may have faced similar issues and can provide insights or solutions.

It's important to note that if Google has acknowledged the issue but not provided a fix, there may be limitations in the service or workarounds that need to be considered until the issue is resolved.

As the issue has persisted for a while, it's a good idea to keep monitoring official updates and fixes from Google Cloud and consider the proposed patch in the issue you mentioned if it appears to be a viable solution.

评论