不允许将文件下载到meta inf文件夹

s3fp2yjn  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(181)

我用的是瓦丁14和上传器。当我要把文件保存到 /META-INF/resources/audio/MyFolderName/MyFileName.mp3 ,然后我得到了这个异常消息: java.nio.file.AccessDeniedException: /META-INF 下面是我的最小代码:

// Write
String audioPath = "/META-INF/resources/audio/" + seletedLanguage.getValue() + "/" + fileName;
Path path = Paths.get(audioPath);
Files.createDirectories(path.getParent()); // <--- Here I got the error
FileOutputStream fos = new FileOutputStream(audioPath);
fos.write(buffer.getInputStream(fileName).readAllBytes());
fos.close();
// Read
String audioPath = "/META-INF/resources/audio/" + seletedLanguage.getValue() + "/" +  foreignSentence + ".mp3";
AbstractStreamResource resource = new StreamResource(foreignSentence, () -> getClass().getResourceAsStream(audioPath));

在哪里 buffer 是从 MultiFileMemoryBuffer 班级。
有人能告诉我有没有可能完全访问 META-INF 瓦丁14号的文件夹?
我的目标是将文件下载到一个文件夹中,以便以后在web应用程序中使用这些文件。
我正在尝试实现这样的目标,以便在打包jar文件之后,可以从本地驱动器(例如projet文件夹)读取和写入文件,或者其他不影响jar文件的东西。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题