xueyiming преди 5 месеца
родител
ревизия
a4215cdef4
променени са 1 файла, в които са добавени 12 реда и са изтрити 2 реда
  1. 12 2
      long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/other/VideoDownloader.java

+ 12 - 2
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/other/VideoDownloader.java

@@ -128,14 +128,24 @@ public class VideoDownloader {
         String index = String.format("%s-%s-%s", platform, videoId, UUID.randomUUID());
         String md5Hash = DigestUtils.md5Hex(index);
         String fileName = String.format("%s.mp4", md5Hash);
-        return String.join(File.separator, ConfigUtil.getConfig("download.path"), fileName); // 返回文件路径和封面路径
+        String path = ConfigUtil.getConfig("download.path");
+        File uploadDir = new File(path);
+        if (!uploadDir.exists()) {
+            uploadDir.mkdirs(); // 创建目录
+        }
+        return String.join(File.separator, path, fileName); // 返回文件路径和封面路径
     }
 
     private static String generateCoverPath(String platform, String videoId) {
         String index = String.format("%s-%s-%s", platform, videoId, UUID.randomUUID());
         String md5Hash = DigestUtils.md5Hex(index);
         String coverName = String.format("%s.png", md5Hash);
-        return String.join(File.separator, ConfigUtil.getConfig("download.path"), coverName); // 返回文件路径和封面路径
+        String path = ConfigUtil.getConfig("download.path");
+        File uploadDir = new File(path);
+        if (!uploadDir.exists()) {
+            uploadDir.mkdirs(); // 创建目录
+        }
+        return String.join(File.separator, path, coverName); // 返回文件路径和封面路径
     }
 
     public static void main(String[] args) {