diff --git a/apps/desktop/src-tauri/src/business/services/volcano_video_service.rs b/apps/desktop/src-tauri/src/business/services/volcano_video_service.rs index 1e468fa..c38c5d4 100644 --- a/apps/desktop/src-tauri/src/business/services/volcano_video_service.rs +++ b/apps/desktop/src-tauri/src/business/services/volcano_video_service.rs @@ -230,9 +230,13 @@ impl VolcanoVideoService { image_upload_result.error_message.unwrap_or_default())); } - let image_url = image_upload_result.remote_url + let image_s3_url = image_upload_result.remote_url .ok_or_else(|| anyhow!("图片上传成功但未返回URL"))?; + // 将S3 URL转换为HTTPS CDN URL + let image_url = Self::convert_s3_to_cdn_url(&image_s3_url); + info!("图片S3 URL: {} -> CDN URL: {}", image_s3_url, image_url); + // 上传驱动视频到云端 info!("正在上传驱动视频到云端: {}", driving_video_path); let video_upload_result = self.cloud_upload_service @@ -244,9 +248,13 @@ impl VolcanoVideoService { video_upload_result.error_message.unwrap_or_default())); } - let driving_video_url = video_upload_result.remote_url + let driving_video_s3_url = video_upload_result.remote_url .ok_or_else(|| anyhow!("驱动视频上传成功但未返回URL"))?; + // 将S3 URL转换为HTTPS CDN URL + let driving_video_url = Self::convert_s3_to_cdn_url(&driving_video_s3_url); + info!("驱动视频S3 URL: {} -> CDN URL: {}", driving_video_s3_url, driving_video_url); + info!("文件上传完成 - 图片: {}, 驱动视频: {}", image_url, driving_video_url); let request_body = VolcanoVideoGenerationRequest { @@ -566,6 +574,28 @@ impl VolcanoVideoService { Ok(hex::encode(signature)) } + + /// 将S3 URL转换为可访问的CDN地址 + fn convert_s3_to_cdn_url(s3_url: &str) -> String { + if s3_url.starts_with("s3://ap-northeast-2/modal-media-cache/") { + // 将 s3://ap-northeast-2/modal-media-cache/ 替换为 https://cdn.roasmax.cn/ + s3_url.replace("s3://ap-northeast-2/modal-media-cache/", "https://cdn.roasmax.cn/") + } else if s3_url.starts_with("s3://") { + // 处理其他 s3:// 格式,转换为通用CDN格式 + s3_url.replace("s3://", "https://cdn.roasmax.cn/") + } else if s3_url.contains("amazonaws.com") { + // 如果是完整的S3 HTTPS URL,提取key部分 + if let Some(key_start) = s3_url.find(".com/") { + let key = &s3_url[key_start + 5..]; + format!("https://cdn.roasmax.cn/{}", key) + } else { + s3_url.to_string() + } + } else { + // 如果不是预期的S3格式,返回原URL + s3_url.to_string() + } + } } // 实现Clone trait以支持异步任务