Reputation: 3340
How can I share file in folder using Spring eg. /tmp/file.mp4
. that it is accessible from the IP? Like this 10.11.14.122/file.mp4
Upvotes: 0
Views: 1184
Reputation: 14217
Your question is need spring-boot
to serve your static files. You just need to configure the path in Override addResourceHandlers
, full code:
@SpringBootApplication
public class TmpApplication extends WebMvcConfigurerAdapter {
public static void main(String[] args) {
SpringApplication.run(TmpApplication.class, args);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/tmp/**").addResourceLocations("file:///./myfolder/")
.setCachePeriod(0);
}
}
There is a document: boot-features-spring-mvc-static-content
Upvotes: 3