K
K
Kassymbekoff2017-06-19 13:47:09
Java
Kassymbekoff, 2017-06-19 13:47:09

Spring Boot + Html5 video. How to show videos that are located in a different system directory?

Good afternoon! There is a web application on Spring Boot. There is a catalog with films, which is located in a separate directory. Import of titles of films realized and I save in a DB. When showing a movie, via the html video tag, there is no access to the video. Error in console: “Not allowed to load local resource: file:///C:…”.
How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
reus, 2017-06-20
@reus

Well, usually such files are in a special direct. media. In short, your web server is configured incorrectly. That is, you need to add your directory to the web server path.

A
Alexander Kosarev, 2017-06-21
@jaxtr

Configuration:

@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/video/**").addResourceLocations("/path/to/video");
    }
}

Thus, the video /path/to/video/kotiki.mp4 on the file system will be available at localhost:8080/video/kotiki.mp4 (example for *nix)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question