I'm using a combination of Spring Boot and JAX-RS for my REST API. In my Spring Java Application I have an image located in my resources directory. I want to serve this picture with an URL, it should be something like this:
localhost:8080/api/get/img/1/imageFileName.png
Like this I should be able to use this URL in my Angular Frontend Application in an img tag:
<img src="localhost:8080/api/get/img/1/imageFileName.png"/>
So the issue is, that I really want to have this stuff in my FileSystem. I definately do not want to return a byte array, but that's the only thing I could find so far. This is the only code I could come up with so far:
@GET
@Path("get/img/1")
public String getFile() {
File file = Paths.get(".", "resources", "Mockup9EventsPageAsMember.png").normalize().toFile();
return file.toString();
}
Obviously this will only return the path to the respective directory and not an URL link which I could use in my img tag.
Any suggestions how I can tell my SpringBoot JAX-RS Application to create an URL for me?