现在许多视频在线观看网站,你如果打开chrome查看其video标签,会发现它的src是一个以
blob:
开头的地址。可以看到他这里引入的并不是一个在线的视频存放地址,这样你通过爬虫脚本也无法下载该视频文件,通过一个new tab打开也于事无补,会提示你地址错误。
-后端实现
//生成视图页面控制器
public ActionResult Index()
{
return View();
}
public void Video()
{
//这里需要获取全路径 如:D:\project\images\video\products\video.mp4
string filePath = this.Server.MapPath("~/images/video/products/video.mp4");
System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
if (fileInfo.Exists == true)
{
FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
//Response.AddHeader("Content-Disposition", "attachment