GoogleCloud Storage - 删除文件?

时间:2017-10-04 03:41:08

标签: google-cloud-storage

我可以看到将文件上传到Google云端存储的a sample。但是,我找不到删除云存储中的文件的示例。是否存在删除文件API?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

def delete_blob(bucket_name, destination_blob_name):
"""Deletes a blob from the bucket."""
try:
    storage_client = storage.Client(project = project)
    bucket = storage_client.get_bucket(bucket_name)
    blob = bucket.blob(destination_blob_name)
    blob.delete()
    log.info('Blob {} deleted.'.format(destination_blob_name))
except Exception as e:
    pass