|
@@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author wenks
|
|
* @author wenks
|
|
@@ -73,19 +74,20 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
|
|
|
// 存储路劲
|
|
// 存储路劲
|
|
|
String storagePath = uploadPath + objectName;
|
|
String storagePath = uploadPath + objectName;
|
|
|
File file = new File(storagePath);
|
|
File file = new File(storagePath);
|
|
|
|
|
+ insUploadFiles.setFilePath(storagePath);
|
|
|
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
|
|
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
|
|
|
if (FileType.IMAGE.getType().equals(type)){
|
|
if (FileType.IMAGE.getType().equals(type)){
|
|
|
// 图片格式需要压缩
|
|
// 图片格式需要压缩
|
|
|
byte[] compressPicByte = ImageCompressionUtils.compressPic(multipartFile.getInputStream(), suffix, uploadFilePath);
|
|
byte[] compressPicByte = ImageCompressionUtils.compressPic(multipartFile.getInputStream(), suffix, uploadFilePath);
|
|
|
byte[] bytes = ImageCompressionUtils.compressPicForScale(compressPicByte, 100);
|
|
byte[] bytes = ImageCompressionUtils.compressPicForScale(compressPicByte, 100);
|
|
|
fileOutputStream.write(bytes);
|
|
fileOutputStream.write(bytes);
|
|
|
- insUploadFiles.setFilePath(storagePath);
|
|
|
|
|
}else {
|
|
}else {
|
|
|
- multipartFile.transferTo(file);
|
|
|
|
|
|
|
+ fileOutputStream.write(multipartFile.getBytes());
|
|
|
}
|
|
}
|
|
|
save(insUploadFiles);
|
|
save(insUploadFiles);
|
|
|
return insUploadFiles;
|
|
return insUploadFiles;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
log.info("上传过程中出错:{}", e.getMessage());
|
|
log.info("上传过程中出错:{}", e.getMessage());
|
|
|
throw new SystemException("上传过程中出错" + e.getMessage());
|
|
throw new SystemException("上传过程中出错" + e.getMessage());
|
|
|
}
|
|
}
|