|
|
@@ -101,6 +101,27 @@ public class MusicInfoServiceImpl extends BaseServiceImpl<Object> implements Mus
|
|
|
imageUrl = parentPath + "/" + newName;
|
|
|
fileMusicCollection.setLowQualityUrl(imageUrl);
|
|
|
}
|
|
|
+ } else if (file != null && StringUtils.isNotEmpty(file.getOriginalFilename()) && "high".equals(qualityType)) {
|
|
|
+ // 1、给上传的图片生成新的文件名
|
|
|
+ // 1.1获取原始文件名
|
|
|
+ String oldName = file.getOriginalFilename();
|
|
|
+ // 1.2使用FtpUtil工具类生成新的文件名,新文件名 = newName + 文件后缀
|
|
|
+ String newName = FtpUtil.genImageName();
|
|
|
+ newName = newName + oldName.substring(oldName.lastIndexOf("."));
|
|
|
+ // 2、把图片上传到图片服务器
|
|
|
+ // 2.1获取上传的io流
|
|
|
+ InputStream input = file.getInputStream();
|
|
|
+
|
|
|
+ // 2.2调用FtpUtil工具类进行上传
|
|
|
+ boolean result = FtpUtil.uploadFile(ftpBasePath, parentPath, newName, input);
|
|
|
+
|
|
|
+ if (result) {
|
|
|
+ imageSize = BigDecimal.valueOf(file.getSize()).divide(new BigDecimal("1048576")).setScale(2, RoundingMode.UP).toPlainString().concat("MB");
|
|
|
+ fileMusicCollection.setSize(imageSize);
|
|
|
+ // 返回给前端图片访问路径
|
|
|
+ imageUrl = parentPath + "/" + newName;
|
|
|
+ fileMusicCollection.setHighQualityUrl(imageUrl);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
fileMusicCollection.setTitle(title);
|
|
|
@@ -197,10 +218,38 @@ public class MusicInfoServiceImpl extends BaseServiceImpl<Object> implements Mus
|
|
|
} else {
|
|
|
throw new BusinessException(ResultCodeEnum.UNKNOWN_ERROR.getCode(), "上传新文件失败!");
|
|
|
}
|
|
|
+ } else if (file != null && StringUtils.isNotEmpty(file.getOriginalFilename()) && "high".equals(qualityType)) {
|
|
|
+ // 1、给上传的图片生成新的文件名
|
|
|
+ // 1.1获取原始文件名
|
|
|
+ String oldName = file.getOriginalFilename();
|
|
|
+ // 1.2使用FtpUtil工具类生成新的文件名,新文件名 = newName + 文件后缀
|
|
|
+ String newName = FtpUtil.genImageName();
|
|
|
+ newName = newName + oldName.substring(oldName.lastIndexOf("."));
|
|
|
+ // 2、把图片上传到图片服务器
|
|
|
+ // 2.1获取上传的io流
|
|
|
+ InputStream input = file.getInputStream();
|
|
|
+
|
|
|
+ // 2.2调用FtpUtil工具类进行上传
|
|
|
+ boolean result = FtpUtil.uploadFile(ftpBasePath, parentPath, newName, input);
|
|
|
+ if (result) {
|
|
|
+ FtpUtil.delFile(ftpBasePath + fileMusicCollection.getHighQualityUrl());
|
|
|
+
|
|
|
+ imageSize = BigDecimal.valueOf(file.getSize()).divide(new BigDecimal("1048576")).setScale(2, RoundingMode.UP).toPlainString().concat("MB");
|
|
|
+ fileMusicCollection.setSize(imageSize);
|
|
|
+ // 返回给前端图片访问路径
|
|
|
+ imageUrl = parentPath + "/" + newName;
|
|
|
+ fileMusicCollection.setHighQualityUrl(imageUrl);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException(ResultCodeEnum.UNKNOWN_ERROR.getCode(), "上传新文件失败!");
|
|
|
+ }
|
|
|
} else if (file != null && StringUtils.isNotEmpty(file.getOriginalFilename()) && "lyric".equals(qualityType)) {
|
|
|
// 1、给上传的图片生成新的文件名
|
|
|
// 1.1获取原始文件名
|
|
|
String lowQualityUrl = fileMusicCollection.getLowQualityUrl();
|
|
|
+ if (StringUtils.isEmpty(lowQualityUrl)) {
|
|
|
+ lowQualityUrl = fileMusicCollection.getHighQualityUrl();
|
|
|
+ }
|
|
|
+
|
|
|
String lyricName = lowQualityUrl.substring(0, lowQualityUrl.lastIndexOf(".")) + ".lrc";
|
|
|
// 2、把图片上传到图片服务器
|
|
|
// 2.1获取上传的io流
|