【问题标题】:Google Cloud Storage file upload issue谷歌云存储文件上传问题
【发布时间】:2019-06-09 13:11:52
【问题描述】:

我无法使用以下链接中的示例将文件上传到 GCS: https://cloud.google.com/python/getting-started/using-cloud-storage

在文件storage.py 上失败,方法:upload_file,完全在以下调用上:

blob.upload_from_string(file_stream, content_type=content_type)

我已按照教程将 ACL 配置为 myu 存储桶并启用所需的 API。我还启用了结算功能。

我在本地开发服务器上运行代码,但使用项目中配置的 GCS 默认存储桶名称。

Python 2.7 版

【问题讨论】:

  • 你能显示回溯吗?
  • 开发服务器并没有真正显示错误或任何东西......它只是显示http 500。即使使用调试标志运行,我猜本地开发服务器也不太适合调试。我发现它在 blob.upload_from_string() 上失败,方法是在 storage.py 文件中的 upload_file() 方法上添加几个日志记录语句
  • 您是否为您的应用启用了调试功能?回溯可能仅在设置标志时显示。
  • 我的主文件中有以下内容: if name == "main": app.debug = True
  • 刚刚启用了一些日志记录,发现以下错误消息:由 SSLError(\"Can\'t connect to HTTPS URL because the SSL module is not available.\",))

标签: google-app-engine google-cloud-platform google-cloud-storage google-app-engine-python


【解决方案1】:

我查看了入门教程,就我所见,它是为在 Python3 运行时使用而构建的。

您可以查看app.yaml 文件,在教程3-binary-data 的情况下,它指定了python3 运行时,并且教程中的所有命令也被认为在Python3 中使用(即virtualenv -p python3 env 构建与 python3 解释器一起使用的环境)。

同样,所使用的库,例如google.cloud.storage在Python 2.7中已被弃用(你可以检查它here),并不是说它在Python2.7中不可用,只是它不受支持,这可能会导致问题。

我建议您使用 Python3 而不是 Python2.7,并检查问题是否仍然存在。

【讨论】:

  • 我在python3环境下运行,运行流畅。看准队友!
猜你喜欢
  • 2018-10-10
  • 1970-01-01
  • 2018-06-16
  • 2019-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-22
  • 1970-01-01
相关资源
最近更新 更多