mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-24 22:17:49 +08:00
Merge pull request #1931 from linwumingshi/fix/download-url
fix: 🐛 修复云录像下载链接中的格式化问题
This commit is contained in:
commit
ed2f104529
@ -2,21 +2,45 @@ package com.genersoft.iot.vmp.utils;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云录像工具类
|
||||||
|
*
|
||||||
|
* @author 648540858
|
||||||
|
*/
|
||||||
|
@UtilityClass
|
||||||
public class CloudRecordUtils {
|
public class CloudRecordUtils {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修复原始工具类中的格式化问题
|
||||||
|
*
|
||||||
|
* @param mediaServerItem 媒体服务器配置
|
||||||
|
* @param filePath 文件路径(可能包含%等特殊字符)
|
||||||
|
* @return 修复后的下载信息
|
||||||
|
*/
|
||||||
public static DownloadFileInfo getDownloadFilePath(MediaServer mediaServerItem, String filePath) {
|
public static DownloadFileInfo getDownloadFilePath(MediaServer mediaServerItem, String filePath) {
|
||||||
DownloadFileInfo downloadFileInfo = new DownloadFileInfo();
|
// 将filePath作为独立参数传入,避免%符号解析问题
|
||||||
|
String pathTemplate = "%s://%s:%s/index/api/downloadFile?file_path=%s";
|
||||||
|
|
||||||
String pathTemplate = "%s://%s:%s/index/api/downloadFile?file_path=" + filePath;
|
DownloadFileInfo info = new DownloadFileInfo();
|
||||||
|
|
||||||
downloadFileInfo.setHttpPath(String.format(pathTemplate, "http", mediaServerItem.getStreamIp(),
|
// filePath作为第4个参数
|
||||||
mediaServerItem.getHttpPort()));
|
info.setHttpPath(String.format(pathTemplate,
|
||||||
|
"http",
|
||||||
|
mediaServerItem.getStreamIp(),
|
||||||
|
mediaServerItem.getHttpPort(),
|
||||||
|
filePath));
|
||||||
|
|
||||||
|
// 同样作为第4个参数
|
||||||
if (mediaServerItem.getHttpSSlPort() > 0) {
|
if (mediaServerItem.getHttpSSlPort() > 0) {
|
||||||
downloadFileInfo.setHttpsPath(String.format(pathTemplate, "https", mediaServerItem.getStreamIp(),
|
info.setHttpsPath(String.format(pathTemplate,
|
||||||
mediaServerItem.getHttpSSlPort()));
|
"https",
|
||||||
|
mediaServerItem.getStreamIp(),
|
||||||
|
mediaServerItem.getHttpSSlPort(),
|
||||||
|
filePath));
|
||||||
}
|
}
|
||||||
return downloadFileInfo;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user