Commit fd523fce by songxiang

fix bug

parent 17724801
......@@ -747,6 +747,36 @@ public class OssUtils {
return resultFileUrl;
}
public static String submitClipJobFixBug(String fileName, String fileUrl, String seek, String duration)
throws FileException {
LOGGER.info("【aliOSS】提交音视频剪切作业(fixBug).<START>.[fileUrl]=" + fileUrl + ",[seek]=" + seek + ",[duration]=" + duration);
if (StringUtil.isEmpty(duration)) {
return null;
}
String fileType = FileUtils.getFileType(fileUrl);
String gatherName = FileUtils.getGatherName(fileType);
if (!(FileUtils.VIDEO.equals(gatherName) || FileUtils.AUDIO.equals(gatherName))) {
return null;
}
String resultFileUrl = "";
String outFileType = FileUtils.VIDEO.equals(gatherName) ? "mp4" : "mp3";
if (StringTools.contains(fileUrl, AliyunConstant.OSS_CDN_URLS)) {
String inObjectKey = splitObjectKey(fileUrl);
String inBucketName = fileUrlExist001(fileUrl) ? AliyunConstant.INPUT_BUCKET
: AliyunConstant.getBucketName(fileUrl);
OSSFileDO ossFileDO = new OSSFileDO(AliyunConstant.getOssRegion(inBucketName), inBucketName, inObjectKey);
String outObjectKey = getOutObjectKeyFixBug(AliyunEnum.CUT.value, fileName, outFileType);
resultFileUrl = clipJob(ossFileDO, outObjectKey, seek, duration);
} else {
String inObjectKey = getInObjectKey(AliyunEnum.CUT.value, fileName, fileType);
OSSFileDO ossFileDO = uploadPointFile2OSS(fileUrl, AliyunConstant.FILE_BUCKET, inObjectKey);
String outObjectKey = getOutObjectKey(AliyunEnum.CUT.value, fileName, outFileType);
resultFileUrl = clipJob(ossFileDO, outObjectKey, seek, duration);
}
LOGGER.info("【aliOSS】提交音视频剪切作业.<END>.[resultFileUrl]=" + resultFileUrl);
return resultFileUrl;
}
/**
* 提交视频剪切作业
*
......@@ -1249,6 +1279,14 @@ public class OssUtils {
.append("/").append(fileName).append(".").append(fileType).toString();
}
private static String getOutObjectKeyFixBug(String uploadType, String fileName, String fileType) {
fileName = StringUtil.isEmpty(fileName) ? UUIDUitl.taskName() : FileUtils.formatName(fileName);
String gatherName = FileUtils.getGatherName(fileType);
gatherName = StringUtil.isEmpty(gatherName) ? "other" : gatherName.toLowerCase();
return new StringBuilder("oss/").append(uploadType).append("/").append(gatherName).append("/").append(fileType)
.append("/").append(fileName).append(".").append(fileType).toString();
}
/**
* 获取文件下载加密密钥,默认有效期48小时 <br>
* 密钥需要结合域名https://download.5rs.me使用,可以在浏览器直接下载 <br>
......@@ -1780,4 +1818,19 @@ public class OssUtils {
return isUploadfe;
}
/**
* 判断文件是存在002中
*
* @param fileUrl
* @return true:001,false:002
*/
public static boolean fileUrlExist002(String fileUrl) {
boolean isUploadfe = false;
String objectKey = splitObjectKey(fileUrl);
if (doesObjectExist(AliyunConstant.FILE_BUCKET, objectKey)) {
isUploadfe = true;
}
return isUploadfe;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment