Team,
I'm trying to parameterize the file name while unzipping the file . But i'm getting below error. It is working when i mention full file name in 'sourceFileObject' and remove match_glob
TypeError: list_blobs() got an unexpected keyword argument 'match_glob'
I'm using : google-cloud-storage==2.5.0 in requirements.txt
please find my sample code below:
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()) ```
match_globis only available since the 2.10 version. Upgrade your dependency to fix the issue https://cloud.google.com/python/docs/reference/storage/2.10.0/google.cloud.storage.bucket.Bucket#google_cloud_storage_bucket_Bucket_list_blobs