fix: 迁移到线上

This commit is contained in:
张德辉 2025-10-20 18:12:34 +08:00
parent 9566f04a7e
commit cb37090515
2 changed files with 22 additions and 8 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@ wheels/
# Virtual environments # Virtual environments
.venv .venv
n8n_video_gen_gui.*
n8n_video_gen_gui.exe

View File

@ -39,7 +39,7 @@ DEFAULT_SELECTED_TEMPLATES = ["妩媚眼神"]
DEFAULT_OUTPUT = "" DEFAULT_OUTPUT = ""
# --- API & S3 配置 --- # --- API & S3 配置 ---
HOST = "http://192.168.0.148:5678" HOST = "https://n8n.bowong.cc"
AWS_ACCESS_KEY_ID = "AKIAYRH5NGRSWHN2L4M6" AWS_ACCESS_KEY_ID = "AKIAYRH5NGRSWHN2L4M6"
AWS_SECRET_ACCESS_KEY = "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" AWS_SECRET_ACCESS_KEY = "kfAqoOmIiyiywi25xaAkJUQbZ/EKDnzvI6NRCW1l"
S3_BUCKET = "modal-media-cache" 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( if not all([AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET]): self.comm.log_signal.emit(
"S3配置不完整无法上传。", logging.ERROR); return None "S3配置不完整无法上传。", logging.ERROR); return None
try: try:
client = boto3.client("s3", aws_access_key_id=AWS_ACCESS_KEY_ID, import mimetypes
aws_secret_access_key=AWS_SECRET_ACCESS_KEY) mime_type = mimetypes.guess_type(file_path)[0]
dest_key = f"upload/{uuid.uuid4()}{os.path.splitext(file_path)[1]}" headers = {
client.upload_file(file_path, S3_BUCKET, dest_key); 'accept': 'application/json',
s3_url = f"https://cdn.roasmax.cn/{dest_key}" 'Mime-Type': mime_type,
self.comm.log_signal.emit(f"图片上传成功: {s3_url}", logging.INFO); }
return s3_url
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: except Exception as e:
self.comm.log_signal.emit(f"图片上传失败: {e}", logging.ERROR); self.comm.log_signal.emit(f"图片上传失败: {e}", logging.ERROR);
return None return None