I am using FileSystemResource and Spring Webflux to serve files from the hard drive.
@GetMapping("/news/file")
fun getImage(@RequestParam name: String): FileSystemResource {
return FileSystemResource(propsStorage.path + "/" + name)
}
When the user requests an unknown file, it should be catched and an 404 error should be returned.
However I get this error:
java.nio.file.NoSuchFileException: C:\Users\SomeUser\Work\posts\32.jpg
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Unfortunately I don't know how to catch the error. You can answer in Java if you want, I can understand both languages.