from fastapi import APIRouter, Depends, File, UploadFile
from api.common.logger import logger

router = APIRouter()

# @router.post("/upload/file/", summary="上传图片")
# async def upload_image( file: UploadFile = File(...) ):
#     logger.info(f"用户{token_data.sub}->上传文件:{file.filename}")
#     # 本地存储临时方案，一般生产都是使用第三方云存储OSS(如七牛云, 阿里云)
#     save_dir = f"{settings.BASE_DIR}/assets"
#     if not os.path.exists(save_dir):
#         os.mkdir(save_dir)
#     try: suffix = Path(file.filename).suffix
#         with NamedTemporaryFile(delete=False, suffix=suffix, dir=save_dir) as tmp:
#             shutil.copyfileobj(file.file, tmp)
#             tmp_file_name = Path(tmp.name).name
#         finally:
#             file.file.close()
#
#     return response_code.resp_200(data={"image": f"http://127.0.0.1:8010/assets/{tmp_file_name}"})
