feat: init files upload/get backend code

This commit is contained in:
swve 2022-12-12 11:08:54 +01:00
parent 805df9b520
commit 4e539865c9
8 changed files with 271 additions and 7 deletions

40
src/routers/files.py Normal file
View file

@ -0,0 +1,40 @@
from fastapi import APIRouter, Depends
from src.dependencies.auth import get_current_user
from fastapi import HTTPException, status, UploadFile
from src.services.files.pictures import create_picture_file, get_picture_file
from src.services.files.videos import create_video_file, get_video_file
from src.services.users import PublicUser
router = APIRouter()
@router.post("/picture")
async def api_create_picture_file(file_object: UploadFile, current_user: PublicUser = Depends(get_current_user)):
"""
Create new picture file
"""
return await create_picture_file(file_object, "ed_123")
@router.post("/video")
async def api_create_video_file(file_object: UploadFile, current_user: PublicUser = Depends(get_current_user)):
"""
Create new video file
"""
return await create_video_file(file_object, "ed_123")
@router.get("/picture")
async def api_get_picture_file(file_id :str ,current_user: PublicUser = Depends(get_current_user)):
"""
Get picture file
"""
return await get_picture_file(file_id, current_user)
@router.get("/video")
async def api_get_video_file(file_id :str ,current_user: PublicUser = Depends(get_current_user)):
"""
Get video file
"""
return await get_video_file(file_id, current_user)