MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / download_file

Function download_file

apps/base/views.py:306–320  ·  view source on GitHub ↗
(key: str, code: str, ip: str = Depends(ip_limit["error"]))

Source from the content-addressed store, hash-verified

304
305@share_api.get("/download")
306async def download_file(key: str, code: str, ip: str = Depends(ip_limit["error"])):
307 file_storage: FileStorageInterface = storages[settings.file_storage]()
308 normalized_code = normalize_share_code(code)
309 if await get_select_token(normalized_code) != key:
310 ip_limit["error"].add_ip(ip)
311 raise HTTPException(status_code=403, detail="下载鉴权失败")
312 has, file_code = await get_code_file_by_code(normalized_code, False)
313 if not has:
314 return APIResponse(code=404, detail="文件不存在")
315 assert isinstance(file_code, FileCodes)
316 return (
317 APIResponse(detail=file_code.text)
318 if file_code.text
319 else await file_storage.get_file_response(file_code)
320 )
321
322
323chunk_api = APIRouter(prefix="/chunk", tags=["切片"])

Callers

nothing calls this directly

Calls 6

get_select_tokenFunction · 0.90
APIResponseClass · 0.90
normalize_share_codeFunction · 0.85
get_code_file_by_codeFunction · 0.85
add_ipMethod · 0.80
get_file_responseMethod · 0.45

Tested by

no test coverage detected