|
@@ -4,19 +4,14 @@ import time
|
|
|
from datetime import timedelta
|
|
|
import datetime
|
|
|
from io import BytesIO
|
|
|
-
|
|
|
-import pytest
|
|
|
from fastapi import Depends, FastAPI, HTTPException, status, UploadFile, APIRouter, File
|
|
|
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
|
|
-from httpx import AsyncClient
|
|
|
from starlette.responses import StreamingResponse, FileResponse
|
|
|
-
|
|
|
-from config.config import MinioOperate ,SetCache
|
|
|
+from config.config import MinioOperate, SetCache
|
|
|
from models.model import *
|
|
|
from utils.jwt import authenticate_user, ACCESS_TOKEN_EXPIRE_MINUTES, create_access_token, get_current_active_user, \
|
|
|
fake_users_db
|
|
|
|
|
|
-
|
|
|
# 创建minio对象
|
|
|
minio_class = MinioOperate()
|
|
|
# 连接minio
|
|
@@ -25,10 +20,11 @@ minio_client = minio_class.link_minio()
|
|
|
minio_class.create_bucket(["file", "image"])
|
|
|
|
|
|
# 初始化缓存
|
|
|
-cache = SetCache(maxsize=128,ttl=10)
|
|
|
+cache = SetCache(maxsize=128, ttl=100)
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
+
|
|
|
@router.post("/token", response_model=Token)
|
|
|
async def login_for_access_token(form_data: OAuth2PasswordRequestForm = Depends()):
|
|
|
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
|
|
@@ -104,6 +100,7 @@ async def download_file(uid: str):
|
|
|
# return response
|
|
|
return {"status": 200, "data": [uid], "msg": ""}
|
|
|
|
|
|
+
|
|
|
# 删除 鉴权 current_user: User = Depends(get_current_active_user)
|
|
|
@router.delete("/file/{uid}")
|
|
|
async def delete_file(uid: str):
|
|
@@ -118,13 +115,3 @@ async def delete_file(uid: str):
|
|
|
return {"status": 200, "data": [], "msg": "Delete Success!"}
|
|
|
except:
|
|
|
return {"status": 404, "data": [], "msg": "Not Found"}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|