python - 如何在Python中从谷歌云存储中的非默认存储桶读取

标签 python google-cloud-platform google-cloud-storage

本文档here说“请注意,如果您不使用默认存储桶,则需要其他方式来提供存储桶名称。”如何提供非默认存储桶?

我知道如何使用 gfile 使用“gs://<bucket_name>//file 语法读取任何存储桶,但这是一个不同的 api。

最佳答案

摘自 open 的文档方法: https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions#open

Arguments

filename (REQUIRED) The file to open, in the format /bucket/object.

您需要提供给 api 的格式是 "/<bucket_name>/<file>"

例如:"/my_bucket/lyrics/southamerica/list5.txt"

这是对 open 的 GitHub 引用方法 https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/master/python/src/cloudstorage/cloudstorage_api.py#L47-L54

关于python - 如何在Python中从谷歌云存储中的非默认存储桶读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51412846/

相关文章:

java - 通过尝试从 Google-Cloud-Storage 读取值来授予无效

python - 使用 Beautifulsoup 传递表格数据

python - 有没有办法将字典的所有值设置为零?

python - 超大表的数据库解决方案

ios - Google 云消息管理控制台

Firebase 收集流到 BigQuery 转换函数

Kubernetes - 将负载均衡的公共(public) IP 作为环境变量传递到 Pod

javascript - firebase 函数中有没有办法删除与正则表达式匹配的存储文件?

python - Google Cloud PostgreSQL 实例的主机名是什么?

python - JSON 列作为 kafka 生产者中的键