File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
examples/as_app/to_gif/lib Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 33import tempfile
44from contextlib import asynccontextmanager
55from os import path
6+ from typing import Annotated
67
78import cv2
89import imageio
910import numpy
10- from fastapi import BackgroundTasks , FastAPI
11+ from fastapi import BackgroundTasks , Depends , FastAPI
1112from pygifsicle import optimize
1213from requests import Response
1314
1617 AppAPIAuthMiddleware ,
1718 LogLvl ,
1819 UiActionFileInfo ,
20+ nc_app ,
1921 run_app ,
2022 set_handlers ,
2123)
@@ -31,8 +33,7 @@ async def lifespan(app: FastAPI):
3133APP .add_middleware (AppAPIAuthMiddleware )
3234
3335
34- def convert_video_to_gif (input_file : FsNode ):
35- nc = NextcloudApp ()
36+ def convert_video_to_gif (input_file : FsNode , nc : NextcloudApp ):
3637 save_path = path .splitext (input_file .user_path )[0 ] + ".gif"
3738 nc .log (LogLvl .WARNING , f"Processing:{ input_file .user_path } -> { save_path } " )
3839 try :
@@ -77,9 +78,10 @@ def convert_video_to_gif(input_file: FsNode):
7778@APP .post ("/video_to_gif" )
7879async def video_to_gif (
7980 file : UiActionFileInfo ,
81+ nc : Annotated [NextcloudApp , Depends (nc_app )],
8082 background_tasks : BackgroundTasks ,
8183):
82- background_tasks .add_task (convert_video_to_gif , file .to_fs_node ())
84+ background_tasks .add_task (convert_video_to_gif , file .to_fs_node (), nc )
8385 return Response ()
8486
8587
You can’t perform that action at this time.
0 commit comments