【问题标题】:how to check if the file is empty or not in google cloud storage using python code in google cloud function如何使用谷歌云功能中的python代码检查谷歌云存储中的文件是否为空
【发布时间】:2021-03-17 13:18:28
【问题描述】:

谁能告诉我如何检查谷歌云存储中的文件是否为空或不使用谷歌云功能中的python。 我需要检查文件是否不为空,为目标系统创建另一个零字节“.done”文件以进行处理,如果文件为空,请不要创建“.done”文件告诉目标系统他们不应处理该文件。

【问题讨论】:

    标签: google-cloud-functions google-cloud-storage


    【解决方案1】:

    您可以在 blob 对象上使用大小功能。

    这里,我列出对象的大小

        from google.cloud import storage
    
        client = storage.Client()
        bucket = client.get_bucket('myBucket')
        blobs = bucket.list_blobs()
        for blob in blobs:
            print(blob.name)
            print(blob.size)
    

    【讨论】:

      猜你喜欢
      • 2021-10-12
      • 2022-12-17
      • 1970-01-01
      • 2019-03-19
      • 2020-09-10
      • 2019-01-19
      • 2017-11-14
      • 2021-08-20
      • 2012-03-02
      相关资源
      最近更新 更多