Explorar el Código

update save_path

xuexiaobo hace 4 años
padre
commit
80947d2c0e

+ 4 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/OSSLogicImpl.java

@@ -552,7 +552,9 @@ public class OSSLogicImpl implements OSSLogic {
         Map<String, Object> result = new HashMap<>();
         try {
             inputStream = file.getInputStream();
-            File localFile = new File("/Users/diors.po/Desktop/" + "slides/" + file.getOriginalFilename());
+            File localFile = new File(SAVE_PATH + "slides/" + file.getOriginalFilename());
+            if (!localFile.getParentFile().exists())
+                localFile.getParentFile().mkdirs();
             FileUtils.copyInputStreamToFile(inputStream, localFile);
             String slidesUrl = uploadByUrl("mooctest-course",
                     "slides/"+file.getOriginalFilename(), new FileInputStream(localFile));
@@ -572,6 +574,7 @@ public class OSSLogicImpl implements OSSLogic {
             result.put("imagesUrl", imagesUrl);
             inputStream.close();
             imagePath.delete();
+            localFile.delete();
         } catch (IOException e) {
             e.printStackTrace();
         }