|
@@ -25,6 +25,7 @@ import org.springframework.web.servlet.HandlerMapping;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
@@ -302,7 +303,9 @@ public class SysFileController {
|
|
|
String uploadFile = spaceFileRecordService.uploadAbsolutePath(URLDecoder.decode(extractedPath, "UTF-8"));
|
|
|
// 构建文件的完整路径
|
|
|
Path filePath = Paths.get(uploadFile);
|
|
|
- Resource resource = new FileSystemResource(filePath.toFile());
|
|
|
+ File file = filePath.toFile();
|
|
|
+ String d0_name = file.getName();
|
|
|
+ Resource resource = new FileSystemResource(file);
|
|
|
// 如果资源不存在,返回404
|
|
|
if (!resource.exists()) {
|
|
|
return ResponseEntity.notFound().build();
|
|
@@ -321,7 +324,7 @@ public class SysFileController {
|
|
|
// String headName = headNames.nextElement();
|
|
|
// headers.set(headName, request.getHeader(headName));
|
|
|
// }
|
|
|
- headers.add(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + URLEncoder.encode(resource.getFilename(), "UTF-8") + "\"");
|
|
|
+ headers.add(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + URLEncoder.encode(d0_name, "UTF-8") + "\"");
|
|
|
headers.setContentType(MediaType.parseMediaType(contentType));
|
|
|
// headers.setAccessControlAllowOrigin("*");
|
|
|
// 返回文件资源
|
|
@@ -351,7 +354,9 @@ public class SysFileController {
|
|
|
String uploadFile = spaceFileRecordService.uploadAbsolutePath(URLDecoder.decode(extractedPath, "UTF-8"));
|
|
|
// 构建文件的完整路径
|
|
|
Path filePath = Paths.get(uploadFile);
|
|
|
- Resource resource = new FileSystemResource(filePath.toFile());
|
|
|
+ File file = filePath.toFile();
|
|
|
+ String d0_name = file.getName();
|
|
|
+ Resource resource = new FileSystemResource(file);
|
|
|
// 如果资源不存在,返回404
|
|
|
if (!resource.exists()) {
|
|
|
return ResponseEntity.notFound().build();
|
|
@@ -365,7 +370,7 @@ public class SysFileController {
|
|
|
// 设置HTTP头部信息
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
// headers.add(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + URLEncoder.encode(resource.getFilename(), "UTF-8") + "\"");
|
|
|
- headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(resource.getFilename() + "\""));
|
|
|
+ headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(d0_name, "UTF-8") + "\"");
|
|
|
headers.setContentType(MediaType.parseMediaType(contentType));
|
|
|
// headers.setAccessControlAllowOrigin("*");
|
|
|
|