|
@@ -31,6 +31,7 @@ import com.platform.service.sb.SbInfoService;
|
|
|
import com.platform.service.upms.SysFileService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.SneakyThrows;
|
|
|
+import net.coobird.thumbnailator.Thumbnails;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -40,8 +41,10 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
@@ -204,7 +207,21 @@ public class IgnoreController {
|
|
|
fileVO.setUrl(path + fileFullName);
|
|
|
fileVO.setFileFormat(fileType);
|
|
|
try {
|
|
|
- FileUtils.uploadFile(file.getBytes(), filePath, fileFullName);
|
|
|
+ if (fileVO.getFileFormat().contains("png") || fileVO.getFileFormat().contains("JPEG")
|
|
|
+ || fileVO.getFileFormat().contains("jpg") || fileVO.getFileFormat().contains("jpeg")
|
|
|
+ || fileVO.getFileFormat().contains("PNG") || fileVO.getFileFormat().contains("JPG")) {
|
|
|
+ File targetFile = new File(filePath);
|
|
|
+ if (!targetFile.exists()) {
|
|
|
+ targetFile.mkdirs();
|
|
|
+ }
|
|
|
+ FileOutputStream out = new FileOutputStream(filePath + fileFullName);
|
|
|
+ Thumbnails.of(file.getInputStream()).scale(1).outputQuality(0.2)
|
|
|
+ .outputFormat(fileFullName.substring(endIndex + 1)).toOutputStream(out);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } else {
|
|
|
+ FileUtils.uploadFile(file.getBytes(), filePath, fileFullName);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
throw new Exception("上传文件失败:" + e.getMessage());
|
|
|
}
|