Explorar el Código

fix:处理临时上传文件无效的问题

liusw hace 6 años
padre
commit
b1ba7f3778
Se han modificado 1 ficheros con 15 adiciones y 0 borrados
  1. 15 0
      sso-server/src/main/java/com/uas/sso/SsoApplication.java

+ 15 - 0
sso-server/src/main/java/com/uas/sso/SsoApplication.java

@@ -4,12 +4,15 @@ import com.uas.sso.util.ContextUtils;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.event.ApplicationPreparedEvent;
+import org.springframework.boot.web.servlet.MultipartConfigFactory;
 import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ImportResource;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 
+import javax.servlet.MultipartConfigElement;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -42,4 +45,16 @@ public class SsoApplication {
         });
         application.run(args);
     }
+
+    @Bean
+    MultipartConfigElement multipartConfigElement() {
+        MultipartConfigFactory factory = new MultipartConfigFactory();
+        String location = "tmp";
+        File tmpFile = new File(location);
+        if (!tmpFile.exists()) {
+            tmpFile.mkdirs();
+        }
+        factory.setLocation(location);
+        return factory.createMultipartConfig();
+    }
 }