java.io.IOException: The temporary upload location [/tmp/tomcat.XX/…] is not valid

Cause Analysis:
Procedures exist for MultipartFile type of operation (such as upload files), the server will temporarily save the file stream in the folder (specific folder by the spring boot at startup, the default is not / tmp folder).
/ tmp folder has an automatic cleanup mechanism, the files for the / tmp folder are not updated for 10 days, and the files for the / var / tmp folder are 30 days old.

solution:

1: specify the directory to prevent the folder is automatically deleted.

@Configuration
public class UploadFileConfigration {
 /**
 * Temporary file upload path
 */
 @Bean
 MultipartConfigElement multipartConfigElement() {
 MultipartConfigFactory factory = new MultipartConfigFactory();
 factory.setLocation("/data/tmp");
 return factory.createMultipartConfig();
 }
}

Solution 2: Tomcat configuration file specified default log, dump and other file directory.

server.tomcat.basedir=/data/tmp

if you want to reproduce, please indicate the source:
java.io.IOException: The temporary upload location [/tmp/tomcat.XX/…] is not valid - CodeDay