From cb37090515ccd10562b396f384104b052a44a7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E8=BE=89?= Date: Mon, 20 Oct 2025 18:12:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=81=E7=A7=BB=E5=88=B0=E7=BA=BF?= =?UTF-8?q?=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ n8n_video_gen_gui.py | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 505a3b1..fdfdcef 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ wheels/ # Virtual environments .venv + +n8n_video_gen_gui.* +n8n_video_gen_gui.exe \ No newline at end of file diff --git a/n8n_video_gen_gui.py b/n8n_video_gen_gui.py index e035f5a..439165c 100644 --- a/n8n_video_gen_gui.py +++ b/n8n_video_gen_gui.py @@ -39,7 +39,7 @@ DEFAULT_SELECTED_TEMPLATES = ["妩媚眼神"] DEFAULT_OUTPUT = "" # --- API & S3 配置 --- -HOST = "http://192.168.0.148:5678" +HOST = "https://n8n.bowong.cc" AWS_ACCESS_KEY_ID = "AKIAYRH5NGRSWHN2L4M6" AWS_SECRET_ACCESS_KEY = "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" S3_BUCKET = "modal-media-cache" @@ -974,13 +974,24 @@ class VideoGeneratorGUI(QWidget): if not all([AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET]): self.comm.log_signal.emit( "S3配置不完整,无法上传。", logging.ERROR); return None try: - client = boto3.client("s3", aws_access_key_id=AWS_ACCESS_KEY_ID, - aws_secret_access_key=AWS_SECRET_ACCESS_KEY) - dest_key = f"upload/{uuid.uuid4()}{os.path.splitext(file_path)[1]}" - client.upload_file(file_path, S3_BUCKET, dest_key); - s3_url = f"https://cdn.roasmax.cn/{dest_key}" - self.comm.log_signal.emit(f"图片上传成功: {s3_url}", logging.INFO); - return s3_url + import mimetypes + mime_type = mimetypes.guess_type(file_path)[0] + headers = { + 'accept': 'application/json', + 'Mime-Type': mime_type, + } + + files = { + 'file': (os.path.basename(file_path), open(file_path, 'rb'), mime_type), + } + + response = requests.post( + 'https://bowongai-prod--text-video-agent-fastapi-app.modal.run/api/file/upload/s3', + headers=headers, + files=files, + ) + self.comm.log_signal.emit(f"图片上传成功: {response.json()}", logging.INFO); + return response.json()['data'] except Exception as e: self.comm.log_signal.emit(f"图片上传失败: {e}", logging.ERROR); return None