4
4
from fastapi import APIRouter , Form , UploadFile , File , Depends , HTTPException
5
5
from starlette import status
6
6
7
- from apps .admin .dependencies import admin_required
7
+ from apps .admin .dependencies import share_required_login
8
8
from apps .base .models import FileCodes , UploadChunk
9
9
from apps .base .schemas import SelectFileModel , InitChunkUploadModel , CompleteUploadModel
10
10
from apps .base .utils import get_expire_info , get_file_path_name , ip_limit , get_chunk_file_path_name
@@ -28,7 +28,7 @@ async def create_file_code(code, **kwargs):
28
28
return await FileCodes .create (code = code , ** kwargs )
29
29
30
30
31
- @share_api .post ("/text/" , dependencies = [Depends (admin_required )])
31
+ @share_api .post ("/text/" , dependencies = [Depends (share_required_login )])
32
32
async def share_text (
33
33
text : str = Form (...),
34
34
expire_value : int = Form (default = 1 , gt = 0 ),
@@ -56,7 +56,7 @@ async def share_text(
56
56
return APIResponse (detail = {"code" : code })
57
57
58
58
59
- @share_api .post ("/file/" , dependencies = [Depends (admin_required )])
59
+ @share_api .post ("/file/" , dependencies = [Depends (share_required_login )])
60
60
async def share_file (
61
61
expire_value : int = Form (default = 1 , gt = 0 ),
62
62
expire_style : str = Form (default = "day" ),
@@ -160,7 +160,7 @@ async def download_file(key: str, code: str, ip: str = Depends(ip_limit["error"]
160
160
chunk_api = APIRouter (prefix = "/chunk" , tags = ["切片" ])
161
161
162
162
163
- @chunk_api .post ("/upload/init/" )
163
+ @chunk_api .post ("/upload/init/" , dependencies = [ Depends ( share_required_login )] )
164
164
async def init_chunk_upload (data : InitChunkUploadModel ):
165
165
# 秒传检查
166
166
existing = await FileCodes .filter (file_hash = data .file_hash ).first ()
@@ -203,7 +203,7 @@ async def init_chunk_upload(data: InitChunkUploadModel):
203
203
})
204
204
205
205
206
- @chunk_api .post ("/upload/chunk/{upload_id}/{chunk_index}" )
206
+ @chunk_api .post ("/upload/chunk/{upload_id}/{chunk_index}" , dependencies = [ Depends ( share_required_login )] )
207
207
async def upload_chunk (
208
208
upload_id : str ,
209
209
chunk_index : int ,
@@ -243,7 +243,7 @@ async def upload_chunk(
243
243
return APIResponse (detail = {"chunk_hash" : chunk_hash })
244
244
245
245
246
- @chunk_api .post ("/upload/complete/{upload_id}" )
246
+ @chunk_api .post ("/upload/complete/{upload_id}" , dependencies = [ Depends ( share_required_login )] )
247
247
async def complete_upload (upload_id : str , data : CompleteUploadModel , ip : str = Depends (ip_limit ["upload" ])):
248
248
# 获取上传基本信息
249
249
chunk_info = await UploadChunk .filter (upload_id = upload_id , chunk_index = - 1 ).first ()
0 commit comments