Commit 44b1f4bd by songxiang

图片转webp格式

parent fd523fce
......@@ -151,6 +151,23 @@ public class OssUtils {
}
/**
* 父子文件上传,子文件全路径和父文件相同,文件后缀类型自定义
*
* @param filePath
* 子文件本地路径
* @param parentFileUrl
* 仅限OSS的全路径,其他本地文件路径均不支持
* @return
* @throws FileException
*/
public static UploadResultInfo uploadLocalFile4Child(String filePath, String parentFileUrl) throws FileException {
String fileType = FileUtils.getFileType(filePath);
String outObjectKey = splitObjectKey(parentFileUrl) + "." + fileType;
uploadPointFile2OSS(filePath, AliyunConstant.FILE_BUCKET, outObjectKey);
return getResultInfo(outObjectKey, new File(filePath).length(), null, AliyunConstant.FILE_BUCKET);
}
/**
* byte[]数组文件流上传 ,isFlag=true,表示上传成功
*
* @param buff
......@@ -747,36 +764,6 @@ 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;
}
/**
* 提交视频剪切作业
*
......@@ -1279,14 +1266,6 @@ 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>
......
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