该文档here说:“请注意,如果您不使用默认存储桶,则需要其他方法来提供存储桶名称。”您如何提供非默认存储桶?
我知道如何使用“ gs://<bucket_name>//file
”语法使用gfile读取任何存储桶,但这是一个不同的api。
答案 0 :(得分:2)
从open
方法的文档中:
https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions#open
参数
文件名(必需)以 / bucket / object 的格式打开的文件。
您需要提供给api的格式是
"/<bucket_name>/<file>"
例如:"/my_bucket/lyrics/southamerica/list5.txt"
这是GitHub对open
方法的引用
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/master/python/src/cloudstorage/cloudstorage_api.py#L47-L54