|
@@ -28,10 +28,6 @@ import javax.annotation.security.PermitAll;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -89,7 +85,7 @@ public class FileController {
|
|
|
@GetMapping("/{configId}/get/**")
|
|
|
@PermitAll
|
|
|
@Operation(summary = "下载文件")
|
|
|
- @Parameter(name = "configId", description = "配置编号", required = true)
|
|
|
+ @Parameter(name = "configId", description = "配置编号", required = true)
|
|
|
public void getFileContent(HttpServletRequest request,
|
|
|
HttpServletResponse response,
|
|
|
@PathVariable("configId") Long configId) throws Exception {
|
|
@@ -106,16 +102,22 @@ public class FileController {
|
|
|
response.setStatus(HttpStatus.NOT_FOUND.value());
|
|
|
return;
|
|
|
}
|
|
|
- ServletUtils.writeAttachment(response, path, content);
|
|
|
+ int lastDotIndex = path.lastIndexOf('.');
|
|
|
+ String type = path.substring(lastDotIndex + 1).toLowerCase();
|
|
|
+ if ("pdf".equals(type)) {
|
|
|
+ ServletUtils.writeInline(response, path, content);
|
|
|
+ } else {
|
|
|
+ ServletUtils.writeAttachment(response, path, content);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@GetMapping("/{configId}/get/video/**")
|
|
|
@PermitAll
|
|
|
@Operation(summary = "下载文件")
|
|
|
- @Parameter(name = "configId", description = "配置编号", required = true)
|
|
|
+ @Parameter(name = "configId", description = "配置编号", required = true)
|
|
|
public void getVideoFileContent(HttpServletRequest request,
|
|
|
- HttpServletResponse response,
|
|
|
- @PathVariable("configId") Long configId) throws Exception {
|
|
|
+ HttpServletResponse response,
|
|
|
+ @PathVariable("configId") Long configId) throws Exception {
|
|
|
// 获取请求的路径
|
|
|
String path = StrUtil.subAfter(request.getRequestURI(), "/get/video/", false);
|
|
|
if (StrUtil.isEmpty(path)) {
|