Added delete_all_objects() for clearing out a bucket
This commit is contained in:
parent
01b0a35298
commit
a21bd5f043
|
|
@ -139,9 +139,16 @@ class S3Storage:
|
||||||
return this_object['Body']
|
return this_object['Body']
|
||||||
|
|
||||||
|
|
||||||
def delete_objects( self ):
|
def delete_all_objects( self, bucket=None ):
|
||||||
"""
|
"""
|
||||||
delete_objects
|
delete_all_objects
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if bucket == None:
|
||||||
|
raise AFS3Error("S3Storage.delete_all_objects(): missing required bucket name")
|
||||||
|
|
||||||
|
objects = self.client.list_objects(Bucket=bucket)
|
||||||
|
for obj in objects['Contents']:
|
||||||
|
self.client.delete_object(Bucket=bucket, Key=obj['Key'])
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue