使用对象存储时,文件管理的在线预览文件中的下载地址修正
This commit is contained in:
@@ -35,7 +35,7 @@ public class FileUploadController extends BaseController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileUploadService fileUploadService;
|
private FileUploadService fileUploadService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件参数
|
* 上传文件参数
|
||||||
*/
|
*/
|
||||||
@@ -53,7 +53,7 @@ public class FileUploadController extends BaseController {
|
|||||||
model.put("imageMaxHeight", Global.getConfigToInteger("file.imageMaxHeight", "768"));
|
model.put("imageMaxHeight", Global.getConfigToInteger("file.imageMaxHeight", "768"));
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件
|
* 上传文件
|
||||||
*/
|
*/
|
||||||
@@ -62,14 +62,14 @@ public class FileUploadController extends BaseController {
|
|||||||
public Map<String, Object> uploadFile(FileUploadParams params) {
|
public Map<String, Object> uploadFile(FileUploadParams params) {
|
||||||
return fileUploadService.uploadFile(new FileUpload(), params);
|
return fileUploadService.uploadFile(new FileUpload(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载文件
|
* 下载文件
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/download/{fileUploadId}")
|
@RequestMapping(value = "/download/{fileUploadId}")
|
||||||
public String downloadFile(@PathVariable("fileUploadId") String fileUploadId, String preview, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public String downloadFile(@PathVariable("fileUploadId") String fileUploadId, String preview, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
FileUpload fileUpload = fileUploadService.getFile(new FileUpload(fileUploadId));
|
FileUpload fileUpload = fileUploadService.getFile(new FileUpload(fileUploadId));
|
||||||
return fileUploadService.downloadFile(fileUpload, preview, request, response);
|
return fileUploadService.downloadFile(fileUpload, preview, "file", request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.io.IOException;
|
|||||||
public class UserfilesController extends BaseController {
|
public class UserfilesController extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(value="/userfiles/**")
|
@RequestMapping(value="/userfiles/**")
|
||||||
public String fileStreamDown(HttpServletRequest request, HttpServletResponse response)
|
public String fileStreamDown(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
// 获取相对文件地址
|
// 获取相对文件地址
|
||||||
@@ -49,7 +49,8 @@ public class UserfilesController extends BaseController {
|
|||||||
String uid = request.getParameter("uid");
|
String uid = request.getParameter("uid");
|
||||||
if (StringUtils.isNotBlank(url) && StringUtils.isNotBlank(uid)){
|
if (StringUtils.isNotBlank(url) && StringUtils.isNotBlank(uid)){
|
||||||
fileUrl = url; //EncodeUtils.decodeUrl(url); 不用解码,否则腾讯云存储的时候预览不能显示
|
fileUrl = url; //EncodeUtils.decodeUrl(url); 不用解码,否则腾讯云存储的时候预览不能显示
|
||||||
fileUri = Global.getCtxPath() + Global.getAdminPath() + "/file/download/" + uid;
|
String type = StringUtils.defaultIfBlank(request.getParameter("type"), "file");
|
||||||
|
fileUri = Global.getCtxPath() + Global.getAdminPath() + "/" + type + "/download/" + uid;
|
||||||
filePath = fileName;
|
filePath = fileName;
|
||||||
} else if (StringUtils.isNotBlank(fileName)){
|
} else if (StringUtils.isNotBlank(fileName)){
|
||||||
fileUri += "?fileName=" + EncodeUtils.encodeUrl(fileName);
|
fileUri += "?fileName=" + EncodeUtils.encodeUrl(fileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user