Miguel Moncada
03/31/2023, 1:29 PMGcsBucket
to delete a blob, or do I need to directly make use of Google's client? 🤔
I couldn't find any after checking here.
Thanks a lot!GcsBucket
class if possible for this task, I can see cloud_storage_copy_blob
but cannot find a way to then remove the "old" blobKevin Grismore
03/31/2023, 2:17 PMBucket
class from the GcsBucket
block, then call its rename_blob
method. Let me grab you some sample code.@task
def rename_blob(path: str):
gcs_bucket = GcsBucket.load('your-bucket-block')
blob_list = gcs_bucket.list_blobs(path)
blobs_to_rename = list(
filter(lambda blob: blob.name.split('/')[-1].startswith('0'), blob_list)
)
for blob in blobs_to_rename:
file_name = '_'.join(blob.name.split('/')[-1].split('_')[1:])
file_path = '/'.join(blob.name.split('/')[:-1])
gcs_bucket.get_bucket().rename_blob(blob, '/'.join([file_path, file_name]))
Miguel Moncada
03/31/2023, 2:21 PMrename_blob
at all 🤷Kevin Grismore
03/31/2023, 2:21 PMrename_blob
does underneath, I haven't actually looked.Miguel Moncada
03/31/2023, 2:21 PMKevin Grismore
03/31/2023, 2:21 PM