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
.venv
n8n_video_gen_gui.*
n8n_video_gen_gui.exe

View File

@ -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