How does one specify a temp directory for file uploads in Spring Boot?

前端 未结 4 1662
太阳男子
太阳男子 2021-02-01 17:42

I\'m using Spring Boot and need to let users upload files for processing. Right now, the file uploads to /home/username/git/myproject which is not great.

How do I make S

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-01 18:19

    On windows versus linux the temp dir could have a trailing slash. Multipart held tmp files that caused new file names. creating my own tmp dir solved the issue.

        String tempDir = System.getProperty("java.io.tmpdir");
        if(  !tempDir.endsWith("/") && !tempDir.endsWith( "\\") ) {
            tempDir = tempDir+"/";
    

提交回复
热议问题