Async I/O implemented
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import aiofiles
|
||||
import re
|
||||
import pickle
|
||||
from secrets import token_urlsafe
|
||||
@@ -59,10 +60,10 @@ async def video_upload(
|
||||
".".join(base_name) + f"_{int(datetime.now().timestamp())}." + extension
|
||||
)
|
||||
|
||||
with open(
|
||||
async with aiofiles.open(
|
||||
path.join("data", "users", current_user.user, "albums", album, filename), "wb"
|
||||
) as f:
|
||||
f.write(await file.read())
|
||||
await f.write(await file.read())
|
||||
|
||||
# Hashing and duplicates check should be here
|
||||
|
||||
@@ -112,8 +113,8 @@ async def video_get(
|
||||
|
||||
mime = Magic(mime=True).from_file(video_path)
|
||||
|
||||
with open(video_path, "rb") as f:
|
||||
video_file = f.read()
|
||||
with aiofiles.open(video_path, "rb") as f:
|
||||
video_file = await f.read()
|
||||
|
||||
return Response(video_file, media_type=mime)
|
||||
|
||||
|
Reference in New Issue
Block a user