团队
我试图在解压缩文件时参数化文件名。但我遇到了以下错误。当我在“sourceFileObject”中提到完整文件名并删除 match_glob 时,它正在工作
类型错误:list_blobs() 获得意外的关键字参数“match_glob”
我在requirements.txt中使用:google-cloud-storage==2.5.0
请在下面找到我的示例代码:
def fileUnzip(data,content):
"""
Decompression logic to unzip a file based on the compression format
"""
storage_client = storage.Client('projectname')
source_bucket = storage_client.get_bucket("bucket-1")
output_bucket = storage_client.get_bucket("bucket-2")
sourceFileObject = "tm*.zip"
if ("*" in sourceFileObject ):
prefix = sourceFileObject.split("*")[0]
delimiter = sourceFileObject.split("*")[-1]
print('prefix is: ', prefix)
print('match_glob is: ', sourceFileObject)
blobs = source_bucket.list_blobs(match_glob=sourceFileObject)
[blob.name for blob in blobs if '*.zip' in blob.name ]
compressedData = io.BytesIO(blobs.download_as_string()) ```