diff --git a/lib_afc_s3storage/s3storage.py b/lib_afc_s3storage/s3storage.py index de844af..f457f52 100755 --- a/lib_afc_s3storage/s3storage.py +++ b/lib_afc_s3storage/s3storage.py @@ -139,9 +139,16 @@ class S3Storage: 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