|
|
@ -178,14 +178,14 @@ public class FileRelationController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String fileName = rewFileRelation.getFilePath();
|
|
|
|
String fileName = rewFileRelation.getFilePath();
|
|
|
|
if (!FileUtils.checkAllowDownload(fileName)) {
|
|
|
|
if (!FileUtils.checkAllowDownload(fileName)) {
|
|
|
|
throw new Exception(com.hyp.common.utils.StringUtils.format("资源文件({})非法,不允许下载。 ", fileName));
|
|
|
|
throw new ServiceException(com.hyp.common.utils.StringUtils.format("资源文件({})非法,不允许下载。 ", fileName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 本地资源路径
|
|
|
|
// 本地资源路径
|
|
|
|
String localPath = HypConfig.getProfile();
|
|
|
|
String localPath = HypConfig.getProfile();
|
|
|
|
// 数据库资源地址
|
|
|
|
// 数据库资源地址
|
|
|
|
String downloadPath = localPath + com.hyp.common.utils.StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
|
|
|
|
String downloadPath = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
|
|
|
|
// 下载名称
|
|
|
|
// 下载名称
|
|
|
|
String downloadName = com.hyp.common.utils.StringUtils.substringAfterLast(downloadPath, "/");
|
|
|
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
|
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
|
|
|
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
|
|
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
|
|
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
|
|
|