我尝试在MultipartFile上使用transferTo
方法,但我在这方面遇到了问题。以下是我的代码:
String videoName = UUID.randomUUID().toString();
File tempVideoFile = new File("src/main/resources/static/campaigns/" + videoName);
//multipart file is video
video.transferTo(tempVideoFile); //this line is what causes an error
这最终会抛出一个IOException
,说JVM找不到指定的路径。这是错误:
Invalid file directoryjava.io.IOException: java.io.FileNotFoundException: C:\Users\Jake\workspace\Test App\src\main\resources\static\temp\work\Tomcat\localhost\ROOT\Test App\src\main\resources\static\campaigns\db95aad3-a3ba-489a-a02e-83f5beece9a7 (The system cannot find the path specified)
不是100%肯定它为什么不起作用,但我认为正确的目录应该是src\main\resources\static\campaigns\db95aad3-a3ba-489a-a02e-83f5beece9a7
而不是Tomcat目录中的目录,但我不确定。< / p>
关于为什么这样做不起作用的任何想法?路径src\main\resources\static\campaigns\
存在,因此我不确定原因。