|
@@ -234,30 +234,29 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
|
|
|
@Override
|
|
|
public void formatMp4(MultipartFile file, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
- String extName = cn.hutool.core.io.FileUtil.extName(file.getOriginalFilename());
|
|
|
- File oldFile = File.createTempFile(UUID.randomUUID().toString() ,extName);
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String suffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
+ File oldFile = File.createTempFile(UUID.randomUUID().toString() ,suffix);
|
|
|
file.transferTo(oldFile);
|
|
|
|
|
|
-// File destFile = File.createTempFile(UUID.randomUUID().toString() ,extName);
|
|
|
- String descFilePath = ConstantFilePath.SCENE_V4_PATH + "abcd/" + file.getOriginalFilename();
|
|
|
- File file1 = new File(descFilePath);
|
|
|
- if(!file1.getParentFile().exists()){
|
|
|
- file1.mkdir();
|
|
|
- }
|
|
|
- CreateObjUtil.formatMp4(oldFile.getPath(), descFilePath);
|
|
|
-
|
|
|
- if(!cn.hutool.core.io.FileUtil.exist(descFilePath)){
|
|
|
+ File destFile = File.createTempFile(UUID.randomUUID().toString() ,suffix);
|
|
|
+// File file1 = new File(descFilePath);
|
|
|
+// if(!file1.getParentFile().exists()){
|
|
|
+// file1.mkdir();
|
|
|
+// }
|
|
|
+ CreateObjUtil.formatMp4(oldFile.getPath(), destFile.getPath());
|
|
|
+//
|
|
|
+ if(!cn.hutool.core.io.FileUtil.exist(destFile.getPath())){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5038);
|
|
|
}
|
|
|
-
|
|
|
- File outFile = new File(descFilePath);
|
|
|
+ File outFile = new File(destFile.getPath());
|
|
|
//定义处理流
|
|
|
try(
|
|
|
FileInputStream inputStream = new FileInputStream(outFile);
|
|
|
OutputStream outputStream = response.getOutputStream()
|
|
|
){
|
|
|
byte[] cache = new byte[1024];
|
|
|
- response.setHeader(HttpHeaders.CONTENT_TYPE, "video/mp4");
|
|
|
+ response.setHeader(HttpHeaders.CONTENT_TYPE, "application/octet-stream");
|
|
|
response.setHeader(HttpHeaders.CONTENT_LENGTH, inputStream.available()+"");
|
|
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(file.getOriginalFilename(), "UTF-8"));
|
|
|
int flag;
|