wangliang 2 vuotta sitten
vanhempi
commit
3752d034da

+ 12 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -790,6 +790,10 @@ public class SystemConstant {
      * @return
      */
     public static File getFileTempVar(String suffix) throws IOException {
+        File fileTmpDir = new File(System.getProperty(SystemConstant.TMP_DIR));
+        if (!fileTmpDir.exists()) {
+            fileTmpDir.mkdirs();
+        }
         File file = File.createTempFile(SystemConstant.TEMP, suffix);
         log.info("getFileTempVar_absolutePath:{}", file.getAbsolutePath());
         return file;
@@ -802,6 +806,10 @@ public class SystemConstant {
      * @return
      */
     public static File getFileTempDirVar(String suffix) {
+        File fileTmpDir = new File(System.getProperty(SystemConstant.TMP_DIR));
+        if (!fileTmpDir.exists()) {
+            fileTmpDir.mkdirs();
+        }
         File file = new File(System.getProperty(SystemConstant.TMP_DIR), SystemConstant.getNanoId() + suffix);
         log.info("getFileTempDirVar_absolutePath:{}", file.getAbsolutePath());
         return file;
@@ -815,6 +823,10 @@ public class SystemConstant {
      * @return
      */
     public static File getFileTempDirVar(String fileName, String suffix) {
+        File fileTmpDir = new File(System.getProperty(SystemConstant.TMP_DIR));
+        if (!fileTmpDir.exists()) {
+            fileTmpDir.mkdirs();
+        }
         String fileNameNew = null;
         if (!StringUtils.isBlank(suffix)) {
             fileNameNew = fileName + suffix;