更改
This commit is contained in:
parent
ae77622325
commit
5cf48298f2
@ -142,6 +142,7 @@ public class CropController {
|
|||||||
|
|
||||||
return saveData(messageList, maxSeq, config, mediaFileInfos, sdk, corpId);
|
return saveData(messageList, maxSeq, config, mediaFileInfos, sdk, corpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步下载待处理的媒体文件
|
* 异步下载待处理的媒体文件
|
||||||
*
|
*
|
||||||
@ -164,6 +165,7 @@ public class CropController {
|
|||||||
mf.setSeq(info.getSeq());
|
mf.setSeq(info.getSeq());
|
||||||
mf.setCropId(corpId);
|
mf.setCropId(corpId);
|
||||||
mf.setStatus(0);
|
mf.setStatus(0);
|
||||||
|
mf.setExt(info.getExt());
|
||||||
return mf;
|
return mf;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
@ -177,13 +179,15 @@ public class CropController {
|
|||||||
}
|
}
|
||||||
return messageList;
|
return messageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步下载待处理的媒体文件
|
* 异步下载待处理的媒体文件
|
||||||
*/
|
*/
|
||||||
private void downloadPendingFiles(List<CropFile> mediaFiles, Long sdk) {
|
private void downloadPendingFiles(List<CropFile> mediaFiles, Long sdk) {
|
||||||
for (CropFile mf : mediaFiles) {
|
for (CropFile mf : mediaFiles) {
|
||||||
try {
|
try {
|
||||||
String url = downFile(mf.getSdkFileId(), mf.getMsgType(),sdk);
|
String msgType = getSuffixByMsgType(mf);
|
||||||
|
String url = downFile(mf.getSdkFileId(), msgType, sdk);
|
||||||
if (url != null && !url.isEmpty()) {
|
if (url != null && !url.isEmpty()) {
|
||||||
mf.setUrl(url);
|
mf.setUrl(url);
|
||||||
mf.setStatus(1);
|
mf.setStatus(1);
|
||||||
@ -201,6 +205,7 @@ public class CropController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提取所有需要下载的媒体文件信息
|
* 提取所有需要下载的媒体文件信息
|
||||||
*/
|
*/
|
||||||
@ -230,10 +235,17 @@ public class CropController {
|
|||||||
if (msg.containsKey(msgType)) {
|
if (msg.containsKey(msgType)) {
|
||||||
String sdkFileId = msg.getJSONObject(msgType).getString("sdkfileid");
|
String sdkFileId = msg.getJSONObject(msgType).getString("sdkfileid");
|
||||||
if (sdkFileId != null && !sdkFileId.trim().isEmpty()) {
|
if (sdkFileId != null && !sdkFileId.trim().isEmpty()) {
|
||||||
CropFile cropFile = new CropFile(); // 注意:你写成了 CropConfig,应为 CropFile
|
CropFile cropFile = new CropFile();
|
||||||
cropFile.setMsgType(msgType);
|
cropFile.setMsgType(msgType);
|
||||||
cropFile.setSeq(seq);
|
cropFile.setSeq(seq);
|
||||||
cropFile.setSdkFileId(sdkFileId);
|
cropFile.setSdkFileId(sdkFileId);
|
||||||
|
cropFile.setSeq(seq);
|
||||||
|
cropFile.setExt(msgType);
|
||||||
|
if (msgType.equals("file")) {
|
||||||
|
String fileext = msg.getJSONObject(msgType).getString("fileext");
|
||||||
|
cropFile.setExt(fileext);
|
||||||
|
}
|
||||||
|
|
||||||
result.add(cropFile);
|
result.add(cropFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,7 +260,9 @@ public class CropController {
|
|||||||
@GetMapping("/crop/downFile")
|
@GetMapping("/crop/downFile")
|
||||||
public String downFile(String sdkField, String msgType, Long sdk) throws IOException {
|
public String downFile(String sdkField, String msgType, Long sdk) throws IOException {
|
||||||
File tempFile = File.createTempFile(GlobalConstants.DOWNLOAD_TEMP_FILE_NAME_PREFIX,
|
File tempFile = File.createTempFile(GlobalConstants.DOWNLOAD_TEMP_FILE_NAME_PREFIX,
|
||||||
getSuffixByMsgType(msgType), mediaContext.getTempMergeFileDir());
|
msgType, mediaContext.getTempMergeFileDir());
|
||||||
|
sdk = sdkManager.initSdk("ww64f47cd0afc456a5", "mEizahrSF6axdfWtSK_f73a3j6-sV02hhyGG7ogmTpM");
|
||||||
|
|
||||||
String indexbuf = null; // 初始化 indexbuf
|
String indexbuf = null; // 初始化 indexbuf
|
||||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -273,8 +287,8 @@ public class CropController {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuffixByMsgType(String msgType) {
|
public String getSuffixByMsgType(CropFile cropFile) {
|
||||||
switch (msgType) {
|
switch (cropFile.getMsgType()) {
|
||||||
case "image":
|
case "image":
|
||||||
return ".jpg";
|
return ".jpg";
|
||||||
case "voice":
|
case "voice":
|
||||||
@ -282,7 +296,7 @@ public class CropController {
|
|||||||
case "video":
|
case "video":
|
||||||
return ".mp4";
|
return ".mp4";
|
||||||
case "file":
|
case "file":
|
||||||
return ".bin";
|
return "." + cropFile.getExt(); // 取真实后缀
|
||||||
default:
|
default:
|
||||||
return ".bin";
|
return ".bin";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public class CropFile {
|
|||||||
|
|
||||||
private String url; // 下载后上传 OSS 的地址
|
private String url; // 下载后上传 OSS 的地址
|
||||||
|
|
||||||
private String fileName; // 可选:原始文件名(后续可补充)
|
private String ext; // 可选:原始文件名(后续可补充)
|
||||||
|
|
||||||
private Integer status = 0; // 0 pending, 1 success, 2 failed
|
private Integer status = 0; // 0 pending, 1 success, 2 failed
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user