Spaces:
Sleeping
Sleeping
Update src/r2_uploader.py
Browse files- src/r2_uploader.py +1 -3
src/r2_uploader.py
CHANGED
|
@@ -2,7 +2,7 @@ import boto3, os
|
|
| 2 |
import logging
|
| 3 |
from uuid import uuid4
|
| 4 |
|
| 5 |
-
def upload_image_to_r2(image_bytes, folder_name="leadgen_vivek", app_type="
|
| 6 |
try:
|
| 7 |
s3 = boto3.client(
|
| 8 |
"s3",
|
|
@@ -17,7 +17,6 @@ def upload_image_to_r2(image_bytes, folder_name="leadgen_vivek", app_type="bulk_
|
|
| 17 |
if folder_name:
|
| 18 |
file_key = f"hug_face/{app_type.strip('/')}/{folder_name.strip('/')}/{filename}"
|
| 19 |
else:
|
| 20 |
-
# If no folder_name provided, just use hug_face/{app_type}/
|
| 21 |
file_key = f"hug_face/{app_type.strip('/')}/{filename}"
|
| 22 |
|
| 23 |
s3.put_object(
|
|
@@ -26,7 +25,6 @@ def upload_image_to_r2(image_bytes, folder_name="leadgen_vivek", app_type="bulk_
|
|
| 26 |
Body=image_bytes,
|
| 27 |
ContentType="image/png"
|
| 28 |
)
|
| 29 |
-
print(f"{os.getenv('NEW_BASE').rstrip('/')}/{file_key}")
|
| 30 |
|
| 31 |
return f"{os.getenv('NEW_BASE').rstrip('/')}/{file_key}"
|
| 32 |
|
|
|
|
| 2 |
import logging
|
| 3 |
from uuid import uuid4
|
| 4 |
|
| 5 |
+
def upload_image_to_r2(image_bytes, folder_name="leadgen_vivek", app_type="bulk_generation"):
|
| 6 |
try:
|
| 7 |
s3 = boto3.client(
|
| 8 |
"s3",
|
|
|
|
| 17 |
if folder_name:
|
| 18 |
file_key = f"hug_face/{app_type.strip('/')}/{folder_name.strip('/')}/{filename}"
|
| 19 |
else:
|
|
|
|
| 20 |
file_key = f"hug_face/{app_type.strip('/')}/{filename}"
|
| 21 |
|
| 22 |
s3.put_object(
|
|
|
|
| 25 |
Body=image_bytes,
|
| 26 |
ContentType="image/png"
|
| 27 |
)
|
|
|
|
| 28 |
|
| 29 |
return f"{os.getenv('NEW_BASE').rstrip('/')}/{file_key}"
|
| 30 |
|