diff options
-rw-r--r-- | fbin/file_storage/s3.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fbin/file_storage/s3.py b/fbin/file_storage/s3.py index 9e68186..a11488f 100644 --- a/fbin/file_storage/s3.py +++ b/fbin/file_storage/s3.py @@ -29,7 +29,11 @@ class Storage(BaseStorage): if not size: obj = self.client.ObjectSummary(self.app.config['S3_BUCKET'], key) size = obj.size - return self.add_file(file_hash, uploaded_file.filename, size, user, ip) + try: + return self.add_file(file_hash, uploaded_file.filename, size, user, ip) + except: + obj.delete() + raise def get_file(self, f, thumb=False): key = self.get_object_key(f, thumb=thumb) |