1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| String repertoireVideo = "C:/xxx/video/";
String nomVideo = request.getParameter("file");
String cheminVideo = repertoireVideo + nomVideo;
response.setContentType("video/mpeg");
response.setHeader("Content-Disposition", "attachment; filename=" + nomVideo);
try {
int l = (int) new File(cheminVideo).length();
response.setContentLength(l);
byte[] b = new byte[l];
FileInputStream f = new FileInputStream(cheminVideo);
f.read(b);
ServletOutputStream o = response.getOutputStream();
o.write(b,0,l);
o.flush();
o.close();
f.close();
} catch (Exception e) {
// nothing
} |
Partager