edit : 원격 저장으로 변경
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
@brief: services api
|
||||
"""
|
||||
|
||||
import requests, json, traceback
|
||||
import requests, json, traceback, os
|
||||
from fastapi import APIRouter, Depends, Body
|
||||
from starlette.requests import Request
|
||||
from typing import Annotated, List
|
||||
@@ -24,6 +24,8 @@ from custom_apps.bingart.bingart import BingArtGenerator
|
||||
from custom_apps.imagen.custom_imagen import imagen_generate_image, imagen_generate_image_path
|
||||
from main_rest.app.utils.parsing_utils import download_range
|
||||
from custom_apps.utils import cookie_manager
|
||||
from utils.custom_sftp import sftp_client
|
||||
from const import REMOTE_FOLDER, TEMP_FOLDER
|
||||
|
||||
router = APIRouter(prefix="/services")
|
||||
|
||||
@@ -176,6 +178,17 @@ async def vactor_image(request: Request, request_body_info: M.VactorImageSearchR
|
||||
if json.loads(vactor_response.text)["error"] != None:
|
||||
raise Exception(f"vactor error: {json.loads(vactor_response.text)['error']}")
|
||||
|
||||
# remote
|
||||
_directory_path, _file = os.path.split(img_path)
|
||||
_base_bame = os.path.basename(_directory_path)
|
||||
|
||||
# remote 폴더 생성
|
||||
sftp_client.remote_mkdir(os.path.join(REMOTE_FOLDER, _base_bame))
|
||||
|
||||
# remote 폴더에 이미지 저장
|
||||
for i in os.listdir(_directory_path):
|
||||
sftp_client.remote_copy_data(local_path=os.path.join(_directory_path, i), remote_path=os.path.join(REMOTE_FOLDER, _base_bame, i))
|
||||
|
||||
return response.set_message()
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user