|
@@ -1,8 +1,23 @@
|
|
package com.kexun.controller;
|
|
package com.kexun.controller;
|
|
-
|
|
|
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.kexun.entity.ModelEntity;
|
|
import com.kexun.entity.ModelEntity;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
|
+import org.springframework.core.io.UrlResource;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
+import java.nio.file.Paths;
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
+import java.util.Base64;
|
|
|
|
+
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
|
|
|
//import ch.qos.logback.core.rolling.helper.FileStoreUtil;
|
|
//import ch.qos.logback.core.rolling.helper.FileStoreUtil;
|
|
//import ch.qos.logback.core.util.FileUtil;
|
|
//import ch.qos.logback.core.util.FileUtil;
|
|
@@ -22,9 +37,7 @@ import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author zhangming
|
|
* @Author zhangming
|
|
@@ -53,6 +66,26 @@ public class FileUploadController {
|
|
@Value("${config.fileupload.warpath}")
|
|
@Value("${config.fileupload.warpath}")
|
|
private String warPath;
|
|
private String warPath;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @GetMapping("/download/{filename}")
|
|
|
|
+ public Result downloadFile(@PathVariable("filename") String filename, SysUser sysUser) throws IOException {
|
|
|
|
+ String filePath = fileuploadPath +sysUser.getUserName()+'/'+ filename; // 设置文件路径
|
|
|
|
+ File file = new File(filePath);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(file.exists()) {
|
|
|
|
+ byte[] fileContent = Files.readAllBytes(file.toPath());
|
|
|
|
+ String base64 = Base64.getEncoder().encodeToString(fileContent);
|
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
|
+ resJson.put("file", base64);
|
|
|
|
+ return Result.success("ok", resJson);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ return Result.error("文件不存在!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
@PostMapping("/filechange")
|
|
@PostMapping("/filechange")
|
|
public Result filechange(@RequestParam Integer index, @RequestParam MultipartFile chunk, @RequestParam String name, @RequestParam Integer chunksLength, @RequestParam String uid
|
|
public Result filechange(@RequestParam Integer index, @RequestParam MultipartFile chunk, @RequestParam String name, @RequestParam Integer chunksLength, @RequestParam String uid
|
|
, @RequestParam String output_list, SysUser sysUser, @RequestParam long id
|
|
, @RequestParam String output_list, SysUser sysUser, @RequestParam long id
|