|
@@ -1,6 +1,8 @@
|
|
|
from typing import Any, List
|
|
|
|
|
|
+from fastapi import UploadFile, File
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
|
+from fastapi.responses import FileResponse
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
import app.crud as crud
|
|
@@ -32,24 +34,33 @@ def get_video_list(
|
|
|
def upload_plot(
|
|
|
*,
|
|
|
db: Session = Depends(deps.get_db),
|
|
|
- video_upload: schemas.VideoUpload,
|
|
|
+ title: str,
|
|
|
+ zip_file: UploadFile=File(),
|
|
|
current_user: models.User = Depends(deps.get_current_active_user),
|
|
|
) -> Any:
|
|
|
"""
|
|
|
Create new video.
|
|
|
"""
|
|
|
video_create = schemas.VideoCreate
|
|
|
- video_create.title = video_upload.title
|
|
|
- video_create.progress = models.Progress.WAITING
|
|
|
- video = crud.item.create_with_owner(db=db, obj_in=video_create, owner_id=current_user.id)
|
|
|
+ video_create.title = title
|
|
|
+ file_name = crud.video.generate_file_name(db=db, n=20)
|
|
|
+ video_create.stored_file_name = file_name
|
|
|
+ video = crud.video.create_with_owner(db=db, obj_in=video_create, owner_id=current_user.id)
|
|
|
return video
|
|
|
|
|
|
-@router.get("/{id}")
|
|
|
+@router.get("/{id}", response_model=FileResponse)
|
|
|
def download_video(
|
|
|
-
|
|
|
+ *,
|
|
|
+ db: Session = Depends(deps.get_db),
|
|
|
+ id: int,
|
|
|
+ current_user: models.User = Depends(deps.get_current_active_user),
|
|
|
) -> Any:
|
|
|
- pass
|
|
|
-
|
|
|
+ video = crud.video.get(db=db, id=id)
|
|
|
+ if video:
|
|
|
+ pass
|
|
|
+ #return FileResponse(path=str(USER_FILE.joinpath(str(id), "output.mp4")), filename=video['filename']+".mp4")
|
|
|
+ else:
|
|
|
+ pass
|
|
|
@router.get("/worker/{id}")
|
|
|
def download_plot(
|
|
|
|