|
|
@@ -1,5 +1,6 @@
|
|
|
package com.anji.sp.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
@@ -7,6 +8,8 @@ import java.util.Objects;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
@@ -138,5 +141,30 @@ public class SpFileUploadController {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/getFile")
|
|
|
+ public Map<String,Object> getFile(@RequestBody String fileKey){
|
|
|
+ JSONObject json = JSONObject.parseObject(fileKey);
|
|
|
+ File file = null;
|
|
|
+ try {
|
|
|
+ file = FileUploadUtils.getFileWithPath(json.getString("fileKey"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ String s = null;
|
|
|
+ try {
|
|
|
+ s = mapper.writeValueAsString(file);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("code", 100);
|
|
|
+ map.put("msg", "操作成功!");
|
|
|
+ map.put("file",s);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|