Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -8,6 +8,7 @@ import requests
|
|
| 8 |
import boto3
|
| 9 |
import base64
|
| 10 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
|
@@ -79,13 +80,14 @@ def init_s3():
|
|
| 79 |
)
|
| 80 |
|
| 81 |
def upload_to_r2(image_bytes):
|
|
|
|
| 82 |
s3_client = init_s3()
|
| 83 |
filename = f"{uuid4().hex}.png"
|
| 84 |
file_key = f"infinityverse/{filename}"
|
| 85 |
s3_client.put_object(
|
| 86 |
Bucket=os.getenv("R2_BUCKET_NAME"),
|
| 87 |
Key=file_key,
|
| 88 |
-
Body=
|
| 89 |
ContentType="image/png",
|
| 90 |
)
|
| 91 |
return f'{os.getenv("NEW_BASE").rstrip("/")}/{file_key}'
|
|
|
|
| 8 |
import boto3
|
| 9 |
import base64
|
| 10 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 11 |
+
from meta_data import meta_data_helper_function
|
| 12 |
|
| 13 |
load_dotenv()
|
| 14 |
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
def upload_to_r2(image_bytes):
|
| 83 |
+
meta_data_img = meta_data_helper_function(image_bytes)
|
| 84 |
s3_client = init_s3()
|
| 85 |
filename = f"{uuid4().hex}.png"
|
| 86 |
file_key = f"infinityverse/{filename}"
|
| 87 |
s3_client.put_object(
|
| 88 |
Bucket=os.getenv("R2_BUCKET_NAME"),
|
| 89 |
Key=file_key,
|
| 90 |
+
Body=meta_data_img,
|
| 91 |
ContentType="image/png",
|
| 92 |
)
|
| 93 |
return f'{os.getenv("NEW_BASE").rstrip("/")}/{file_key}'
|