I have small videos total of 540mb in src/resources/static. Is being too big a problem for .war file? I will deploy it to tomcat now. If it is a problem, how can I solve this problem? Because I cannot play local videos from javascript (with file:///) at Chrome. Hence, I must put them at the project directory.
Asked
Active
Viewed 255 times
2 Answers
2
You can move the videos out to a separate location on the server:
Simplest way to serve static data from outside the application server in a Java web application
Or you could host them on another service (AWS S3?) and provide an endpoint to proxy them

Daniel Scott
- 7,418
- 5
- 39
- 58
-
I am using digitalocean 5$ droplet currently. – funky-nd Apr 10 '18 at 20:26
-
thanks, I got the idea from the best answer from the link you have provided. – funky-nd Apr 10 '18 at 20:29
0
My solution:
package com.youtalkwesign.controller;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@Controller
public class VideoController {
@GetMapping("sign-videos/{word}")
protected void doGet(@PathVariable String word, HttpServletResponse response) throws IOException {
File file = new File("home/sign-videos/" + word + ".mp4"); // TODO: D:/sign-videos/ or home/sign-videos/
response.setHeader("Content-Type", "video/mp4");
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");
Files.copy(file.toPath(), response.getOutputStream());
}
}

funky-nd
- 637
- 1
- 9
- 25