|
@@ -1,4 +1,6 @@
|
|
|
package com.kexun.controller;
|
|
|
+
|
|
|
+import net.coobird.thumbnailator.Thumbnails;
|
|
|
import org.springframework.core.io.FileSystemResource;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.kexun.entity.ModelEntity;
|
|
@@ -8,6 +10,8 @@ import org.springframework.core.io.UrlResource;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
+import java.awt.*;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.file.Path;
|
|
@@ -36,8 +40,11 @@ import org.springframework.util.FileCopyUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.swing.*;
|
|
|
+import javax.swing.filechooser.FileSystemView;
|
|
|
|
|
|
/**
|
|
|
* @Author zhangming
|
|
@@ -69,18 +76,17 @@ public class FileUploadController {
|
|
|
|
|
|
@GetMapping("/download/{filename}")
|
|
|
public Result downloadFile(@PathVariable("filename") String filename, SysUser sysUser) throws IOException {
|
|
|
- String filePath = fileuploadPath +sysUser.getUserName()+'/'+ filename; // 设置文件路径
|
|
|
+ String filePath = fileuploadPath + sysUser.getUserName() + '/' + filename; // 设置文件路径
|
|
|
File file = new File(filePath);
|
|
|
|
|
|
|
|
|
- if(file.exists()) {
|
|
|
+ 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{
|
|
|
+ } else {
|
|
|
return Result.error("文件不存在!");
|
|
|
}
|
|
|
|
|
@@ -133,7 +139,7 @@ public class FileUploadController {
|
|
|
modelEntity.setFilePath(filePath);
|
|
|
userModelService.updateById(modelEntity);
|
|
|
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
resJson.put("file_path", filePath);
|
|
|
|
|
|
return Result.success("ok", resJson);
|
|
@@ -143,7 +149,7 @@ public class FileUploadController {
|
|
|
@PostMapping("/fileupload")
|
|
|
@ResponseBody
|
|
|
public Result upload2(@RequestParam Integer index, @RequestParam MultipartFile chunk, @RequestParam String name, @RequestParam Integer chunksLength, @RequestParam String uid
|
|
|
- , @RequestParam String model_name, @RequestParam String model_type,@RequestParam String model_no, @RequestParam String output_list, SysUser sysUser
|
|
|
+ , @RequestParam String model_name, @RequestParam String model_type, @RequestParam String model_no, @RequestParam String output_list, SysUser sysUser
|
|
|
) throws IOException {
|
|
|
int type = Integer.parseInt(model_type);
|
|
|
if (type == 1 || type == 2) {
|