From dcaf3e6678cdab9e95a20118b464ceb7fe239598 Mon Sep 17 00:00:00 2001 From: coder_wen Date: Mon, 16 Dec 2024 15:14:16 +0800 Subject: [PATCH] fix: change alist.py upload api to put, fix big file upload over memory limit #3265 --- app/modules/filemanager/storages/alist.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/modules/filemanager/storages/alist.py b/app/modules/filemanager/storages/alist.py index 5be0cdb5..af411c27 100644 --- a/app/modules/filemanager/storages/alist.py +++ b/app/modules/filemanager/storages/alist.py @@ -553,15 +553,15 @@ class Alist(StorageBase, metaclass=Singleton): :param new_name: 上传后文件名 :param task: 是否为任务,默认为False避免未完成上传时对文件进行操作 """ - encoded_path = UrlUtils.quote(fileitem.path) + encoded_path = UrlUtils.quote(fileitem.path + path.name) headers = self.__get_header_with_token() - headers.setdefault("Content-Type", "multipart/form-data") + headers.setdefault("Content-Type", "application/octet-stream") headers.setdefault("As-Task", str(task).lower()) headers.setdefault("File-Path", encoded_path) with open(path, "rb") as f: resp: Response = RequestUtils(headers=headers).put_res( - self.__get_api_url("/api/fs/form"), - data={"file": f}, + self.__get_api_url("/api/fs/put"), + data=f, ) if resp.status_code != 200: