|
@@ -1,6 +1,6 @@
|
|
|
-from typing import Any, List
|
|
|
+from typing import Any, List, Optional
|
|
|
|
|
|
-from fastapi import UploadFile, File
|
|
|
+from fastapi import UploadFile, File, Form
|
|
|
from fastapi.responses import FileResponse
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
|
from sqlalchemy.orm import Session
|
|
@@ -11,11 +11,11 @@ import app.schemas as schemas
|
|
|
from app.api import deps
|
|
|
|
|
|
from app.core.celery_app import celery_app
|
|
|
-
|
|
|
+from app.core.config import settings
|
|
|
from pathlib import Path
|
|
|
|
|
|
-ZIP_STORAGE = "/app/backend/zips"
|
|
|
-VIDEO_STORAGE = "/app/backend/videos"
|
|
|
+ZIP_STORAGE = Path("/app").joinpath(settings.BACKEND_ZIP_STORAGE)
|
|
|
+VIDEO_STORAGE = Path("/app").joinpath(settings.BACKEND_VIDEO_STORAGE)
|
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
@@ -38,23 +38,21 @@ def get_video_list(
|
|
|
)
|
|
|
return videos
|
|
|
|
|
|
-@router.post("/", response_model=schemas.Item)
|
|
|
+@router.post("/", response_model=schemas.Video)
|
|
|
def upload_plot(
|
|
|
*,
|
|
|
db: Session = Depends(deps.get_db),
|
|
|
- title: str,
|
|
|
+ title: str=Form(...),
|
|
|
upload_file: UploadFile=File(),
|
|
|
current_user: models.User = Depends(deps.get_current_active_user),
|
|
|
) -> Any:
|
|
|
"""
|
|
|
Create new video.
|
|
|
"""
|
|
|
- video_create = schemas.VideoCreate
|
|
|
- video_create.title = title
|
|
|
- video_create.progress = models.Progress.WAITING
|
|
|
- video_create.title = title
|
|
|
+ print(title)
|
|
|
+ print(upload_file.filename)
|
|
|
file_name = crud.video.generate_file_name(db=db, n=20)
|
|
|
- video_create.stored_file_name = file_name
|
|
|
+ video_create = schemas.VideoCreate(title=title, progress_state="waiting", stored_file_name=file_name)
|
|
|
video = crud.video.create_with_owner(db=db, obj_in=video_create, owner_id=current_user.id)
|
|
|
|
|
|
try:
|
|
@@ -110,7 +108,8 @@ def upload_complete_video(
|
|
|
*,
|
|
|
db: Session = Depends(deps.get_db),
|
|
|
id: int,
|
|
|
- upload_video: UploadFile=File(),
|
|
|
+ upload_video: Optional[UploadFile]=None,
|
|
|
+ result:int=Form(...)
|
|
|
) -> Any:
|
|
|
|
|
|
video = db.query(models.Video).filter(db=db, id=id).first()
|