Spaces:
Build error
Build error
Commit ·
452c5ca
1
Parent(s): d9fa998
refactor: try put_object instead of upload_fileobj
Browse files- apis/s3.py +13 -6
apis/s3.py
CHANGED
|
@@ -36,14 +36,21 @@ class S3:
|
|
| 36 |
def upload_file(self, bucket_name, file, name, req_id):
|
| 37 |
res = Response()
|
| 38 |
try:
|
| 39 |
-
self.client.upload_fileobj(
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
Bucket=bucket_name,
|
| 42 |
Key=name,
|
| 43 |
-
|
| 44 |
-
'
|
| 45 |
-
'x-request-id': req_id,
|
| 46 |
-
}
|
| 47 |
})
|
| 48 |
res.status = 200
|
| 49 |
except botocore.exceptions.ClientError as error:
|
|
|
|
| 36 |
def upload_file(self, bucket_name, file, name, req_id):
|
| 37 |
res = Response()
|
| 38 |
try:
|
| 39 |
+
# self.client.upload_fileobj(
|
| 40 |
+
# Fileobj=file,
|
| 41 |
+
# Bucket=bucket_name,
|
| 42 |
+
# Key=name,
|
| 43 |
+
# ExtraArgs={
|
| 44 |
+
# 'Metadata': {
|
| 45 |
+
# 'x-request-id': req_id,
|
| 46 |
+
# }
|
| 47 |
+
# })
|
| 48 |
+
self.client.put_object(
|
| 49 |
+
Body=file,
|
| 50 |
Bucket=bucket_name,
|
| 51 |
Key=name,
|
| 52 |
+
Metadata={
|
| 53 |
+
'x-request-id': req_id,
|
|
|
|
|
|
|
| 54 |
})
|
| 55 |
res.status = 200
|
| 56 |
except botocore.exceptions.ClientError as error:
|