|
@@ -45,6 +45,8 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
|
|
|
@Value("${upload.file.url}")
|
|
@Value("${upload.file.url}")
|
|
|
private String uploadFileUrl;
|
|
private String uploadFileUrl;
|
|
|
|
|
|
|
|
|
|
+ private static final int desFileSize = 300;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public InsUploadFiles uploadFile(MultipartFile multipartFile, String username, String type) throws IOException {
|
|
public InsUploadFiles uploadFile(MultipartFile multipartFile, String username, String type) throws IOException {
|
|
|
String fileMD5 = DigestUtils.md5Hex(multipartFile.getBytes());
|
|
String fileMD5 = DigestUtils.md5Hex(multipartFile.getBytes());
|
|
@@ -88,9 +90,9 @@ public class InsUploadFilesServiceImpl extends ServiceImpl<InsUploadFilesMapper,
|
|
|
byte[] compressPicByte = ImageCompressionUtils.compressPic(multipartFile.getInputStream(), suffix, uploadFilePath);
|
|
byte[] compressPicByte = ImageCompressionUtils.compressPic(multipartFile.getInputStream(), suffix, uploadFilePath);
|
|
|
|
|
|
|
|
if (compressPicByte.length > length) {
|
|
if (compressPicByte.length > length) {
|
|
|
- bytes = ImageCompressionUtils.compressPicForScale(multipartFile.getBytes(), 100);
|
|
|
|
|
|
|
+ bytes = ImageCompressionUtils.compressPicForScale(multipartFile.getBytes(), desFileSize);
|
|
|
} else {
|
|
} else {
|
|
|
- bytes = ImageCompressionUtils.compressPicForScale(compressPicByte, 100);
|
|
|
|
|
|
|
+ bytes = ImageCompressionUtils.compressPicForScale(compressPicByte, desFileSize);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fileOutputStream.write(bytes);
|
|
fileOutputStream.write(bytes);
|