@RequestMapping(value = "/video_CNDown")
@ResponseBody
public Object video_CNDown(HttpServletResponse response) {
start();
FileInputStream fin = null;
OutputStream output = null;
try {
Properties prop = new Properties();
InputStream ins = this.getClass().getResourceAsStream("/config/videoUrl.properties");
prop.load(ins);
String videoFilePath = prop.getProperty("VIDEO_ENURL");//视频文件路径
File videoFile = new File(videoFilePath);
output = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment; filename="+videoFile);
fin = new FileInputStream(videoFile);
byte[] arr = new byte[1024 * 10];
int n;
while ((n = fin.read(arr)) != -1) {
output.write(arr, 0, n);
}
output.flush();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
return end();
}
自定义视频文件路径供下载并指定下载后的文件名------Demo(文件路径可读取.properties文件)
最新推荐文章于 2022-12-06 21:49:38 发布