Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -74,7 +74,7 @@ async def decrypt_and_upload(
|
|
74 |
):
|
75 |
try:
|
76 |
# Download file data from the URL
|
77 |
-
response = requests.get(url)
|
78 |
if response.status_code != 200:
|
79 |
return JSONResponse(content={"error": "Failed to download the file."}, status_code=400)
|
80 |
|
@@ -87,10 +87,10 @@ async def decrypt_and_upload(
|
|
87 |
mediaKeyExpanded[16:48], mediaData[:-10], mediaKeyExpanded[:16]
|
88 |
)
|
89 |
|
90 |
-
#
|
91 |
-
upload_result = cloudinary.uploader.
|
92 |
decrypted_data,
|
93 |
-
resource_type="raw", # Resource type for raw files
|
94 |
format=extension.get(media_type, "bin")
|
95 |
)
|
96 |
file_url = upload_result.get("url")
|
@@ -101,6 +101,7 @@ async def decrypt_and_upload(
|
|
101 |
except Exception as e:
|
102 |
return JSONResponse(content={"error": str(e)}, status_code=500)
|
103 |
|
|
|
104 |
# Root endpoint
|
105 |
@app.get("/")
|
106 |
def root():
|
|
|
74 |
):
|
75 |
try:
|
76 |
# Download file data from the URL
|
77 |
+
response = requests.get(url, stream=True)
|
78 |
if response.status_code != 200:
|
79 |
return JSONResponse(content={"error": "Failed to download the file."}, status_code=400)
|
80 |
|
|
|
87 |
mediaKeyExpanded[16:48], mediaData[:-10], mediaKeyExpanded[:16]
|
88 |
)
|
89 |
|
90 |
+
# Use chunked upload for large files
|
91 |
+
upload_result = cloudinary.uploader.upload_large(
|
92 |
decrypted_data,
|
93 |
+
resource_type="raw", # Resource type for raw files
|
94 |
format=extension.get(media_type, "bin")
|
95 |
)
|
96 |
file_url = upload_result.get("url")
|
|
|
101 |
except Exception as e:
|
102 |
return JSONResponse(content={"error": str(e)}, status_code=500)
|
103 |
|
104 |
+
|
105 |
# Root endpoint
|
106 |
@app.get("/")
|
107 |
def root():
|