代码之家  ›  专栏  ›  技术社区  ›  netskink

如何读取python中google云存储中的非缺省bucket

  •  1
  • netskink  · 技术社区  · 8 年前

    本文件 here 说:“注意,如果不使用默认bucket,就需要其他方法来提供bucket名称。”如何提供非默认bucket?

    我知道如何使用gfile读取任何使用 gs://<bucket_name>//file 但这是一个不同的API。

    1 回复  |  直到 7 年前
        1
  •  2
  •   ScottMcC    8 年前

    从文档中 open 方法: https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions#open

    论据

    文件名(必需)要打开的文件,格式为 /桶/物体 .

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

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

    这是对 打开 方法 https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/master/python/src/cloudstorage/cloudstorage_api.py#L47-L54