Explorar o código

导览视频转换下载

dengsixing %!s(int64=2) %!d(string=hai) anos
pai
achega
e4721d2c26

+ 14 - 6
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneUploadServiceImpl.java

@@ -237,14 +237,15 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
         File oldFile = File.createTempFile(UUID.randomUUID().toString() ,extName);
         file.transferTo(oldFile);
 
-        File destFile = File.createTempFile(UUID.randomUUID().toString() ,extName);
-        CreateObjUtil.formatMp4(oldFile.getPath(), destFile.getPath());
+//        File destFile = File.createTempFile(UUID.randomUUID().toString() ,extName);
+        String descFilePath = ConstantFilePath.SCENE_V4_PATH + "abcd/" + file.getOriginalFilename();
+        CreateObjUtil.formatMp4(oldFile.getPath(), descFilePath);
 
-        if(!cn.hutool.core.io.FileUtil.exist(destFile.getPath())){
+        if(!cn.hutool.core.io.FileUtil.exist(descFilePath)){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5038);
         }
 
-        File outFile = new File(destFile.getPath());
+        File outFile = new File(descFilePath);
         //定义处理流
         try(
             InputStream inputStream = new BufferedInputStream(new FileInputStream(outFile));
@@ -267,8 +268,15 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
             //刷新输出流,否则不会写出数据
             outputStream.flush();
         }finally {
-            FileUtil.delFile(oldFile.getPath());
-            FileUtil.delFile(destFile.getPath());
+//            FileUtil.delFile(oldFile.getPath());
+//            FileUtil.delFile(destFile.getPath());
         }
     }
+
+    public static void main(String[] args) {
+        File file = new File("C:\\Users\\4dage\\Desktop\\screencap.mp4");
+        System.out.println(file.length());
+        File file2 = new File("C:\\Users\\4dage\\Desktop\\abc.mp4");
+        System.out.println(file2.length());
+    }
 }