Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,6 @@ from fastapi.responses import HTMLResponse, JSONResponse, StreamingResponse
|
|
3 |
import aiohttp
|
4 |
import asyncio
|
5 |
from typing import Dict
|
6 |
-
import base64
|
7 |
-
import hmac
|
8 |
-
import hashlib
|
9 |
-
import time
|
10 |
|
11 |
app = FastAPI()
|
12 |
|
@@ -1027,7 +1023,7 @@ async def initiate_upload(cookies: Dict[str, str], filename: str, content_type:
|
|
1027 |
|
1028 |
async def chunked_upload(upload_url: str, file: UploadFile, content_type: str, chunk_size: int = 1024 * 1024) -> bool:
|
1029 |
async with aiohttp.ClientSession() as session:
|
1030 |
-
file_size = await file
|
1031 |
await file.seek(0)
|
1032 |
|
1033 |
for start in range(0, file_size, chunk_size):
|
@@ -1053,6 +1049,12 @@ async def chunked_upload(upload_url: str, file: UploadFile, content_type: str, c
|
|
1053 |
|
1054 |
return True
|
1055 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1056 |
if __name__ == "__main__":
|
1057 |
import uvicorn
|
1058 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
3 |
import aiohttp
|
4 |
import asyncio
|
5 |
from typing import Dict
|
|
|
|
|
|
|
|
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
1023 |
|
1024 |
async def chunked_upload(upload_url: str, file: UploadFile, content_type: str, chunk_size: int = 1024 * 1024) -> bool:
|
1025 |
async with aiohttp.ClientSession() as session:
|
1026 |
+
file_size = await get_file_size(file)
|
1027 |
await file.seek(0)
|
1028 |
|
1029 |
for start in range(0, file_size, chunk_size):
|
|
|
1049 |
|
1050 |
return True
|
1051 |
|
1052 |
+
async def get_file_size(file: UploadFile) -> int:
|
1053 |
+
await file.seek(0, 2)
|
1054 |
+
size = file.tell()
|
1055 |
+
await file.seek(0)
|
1056 |
+
return size
|
1057 |
+
|
1058 |
if __name__ == "__main__":
|
1059 |
import uvicorn
|
1060 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|