Spaces:
Runtime error
Runtime error
Update upload_to_s3.py
Browse files- upload_to_s3.py +8 -1
upload_to_s3.py
CHANGED
|
@@ -18,7 +18,13 @@ s3_client = boto3.client(
|
|
| 18 |
region_name=region
|
| 19 |
)
|
| 20 |
|
| 21 |
-
def upload_file_to_s3(local_path, bucket, s3_key):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
try:
|
| 23 |
s3_client.upload_file(local_path, bucket, s3_key)
|
| 24 |
print(f" Uploaded: {local_path} → s3://{bucket}/{s3_key}")
|
|
@@ -26,3 +32,4 @@ def upload_file_to_s3(local_path, bucket, s3_key):
|
|
| 26 |
except (BotoCoreError, ClientError) as e:
|
| 27 |
print(f" Upload failed: {e}")
|
| 28 |
return False
|
|
|
|
|
|
| 18 |
region_name=region
|
| 19 |
)
|
| 20 |
|
| 21 |
+
def upload_file_to_s3(local_path, bucket, s3_key, aws_access_key, aws_secret_key, region):
|
| 22 |
+
s3_client = boto3.client(
|
| 23 |
+
"s3",
|
| 24 |
+
aws_access_key_id=aws_access_key,
|
| 25 |
+
aws_secret_access_key=aws_secret_key,
|
| 26 |
+
region_name=region
|
| 27 |
+
)
|
| 28 |
try:
|
| 29 |
s3_client.upload_file(local_path, bucket, s3_key)
|
| 30 |
print(f" Uploaded: {local_path} → s3://{bucket}/{s3_key}")
|
|
|
|
| 32 |
except (BotoCoreError, ClientError) as e:
|
| 33 |
print(f" Upload failed: {e}")
|
| 34 |
return False
|
| 35 |
+
|