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