如何使用python

时间:2018-07-19 00:54:29

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

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

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

1 个答案:

答案 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