(self, file_id: int)
| 1427 | return sort_map.get(sort_by) |
| 1428 | |
| 1429 | async def download_file(self, file_id: int): |
| 1430 | file_code = await FileCodes.filter(id=file_id).first() |
| 1431 | if not file_code: |
| 1432 | raise HTTPException(status_code=404, detail="文件不存在") |
| 1433 | if file_code.text: |
| 1434 | return APIResponse(detail=file_code.text) |
| 1435 | else: |
| 1436 | return await self.file_storage.get_file_response(file_code) |
| 1437 | |
| 1438 | async def preview_file(self, file_id: int, max_chars: int = 4000): |
| 1439 | max_chars = min(max(max_chars, 1), 20000) |
no test coverage detected