From 6eed0f2f18610534e9afba58dba75c0707030be5 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 20 Dec 2024 17:04:48 +0800 Subject: [PATCH] bugfix --- ahserver/filedownload.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ahserver/filedownload.py b/ahserver/filedownload.py index 966ae84..20c0eaf 100644 --- a/ahserver/filedownload.py +++ b/ahserver/filedownload.py @@ -1,13 +1,14 @@ import os import asyncio +import aiofiles import mimetypes from aiohttp.web_exceptions import HTTPNotFound from aiohttp.web import StreamResponse from aiohttp import web -import aiofiles - from appPublic.rc4 import RC4 +from appPublic.registerfunction import RegisterFunction +from .filestorage import FileStorage crypto_aim = 'God bless USA and others' def path_encode(path): @@ -52,3 +53,14 @@ async def file_download(request, filepath, content_type=None): await response.write_eof() return response raise HTTPNotFound + +async def path_download(request, kw, *params): + path = kw.get('path') + fs = FileStorage() + fp = fs.realPath(path) + return await file_download(request, fp) + +rf = RegisterFunction('download_path', path_download) + + +