Spaces:
Runtime error
Runtime error
Update remote_uploader.py
Browse files- remote_uploader.py +5 -3
remote_uploader.py
CHANGED
@@ -22,9 +22,11 @@ class WebSocketFileUploader:
|
|
22 |
async def connect_and_upload(self, upload_dir):
|
23 |
"""连接到 WebSocket 服务器并上传文件"""
|
24 |
|
25 |
-
# 修复点:
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
ws_url += f'/ws/upload/{self.space_id}?token={self.api_key}'
|
29 |
|
30 |
logger.info(f"正在连接到 WebSocket: {ws_url}")
|
|
|
22 |
async def connect_and_upload(self, upload_dir):
|
23 |
"""连接到 WebSocket 服务器并上传文件"""
|
24 |
|
25 |
+
# --- 修复点: 统一将 URL 转换为小写,以处理类似 "HTTPS" 这样的异常情况 ---
|
26 |
+
normalized_server_url = self.server_url.lower()
|
27 |
+
|
28 |
+
# 使用转换后的 URL 进行协议替换
|
29 |
+
ws_url = normalized_server_url.replace('https://', 'wss://').replace('http://', 'ws://').rstrip('/')
|
30 |
ws_url += f'/ws/upload/{self.space_id}?token={self.api_key}'
|
31 |
|
32 |
logger.info(f"正在连接到 WebSocket: {ws_url}")
|