首页 > 其他 > 详细

下载文件

时间:2021-01-29 15:06:10      阅读:17      评论:0      收藏:0      [点我收藏+]

 

//添加地址

HttpWebRequest requestUrl = (HttpWebRequest)WebRequest.Create(url);
requestUrl.Method = "GET";
requestUrl.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
requestUrl.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9");
requestUrl.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
HttpWebResponse responseUrl = (HttpWebResponse)requestUrl.GetResponse();
string urlRe = responseUrl.ResponseUri.ToString();
//模拟请求视频
HttpWebRequest requesturlRe = (HttpWebRequest)WebRequest.Create(urlRe);
HttpWebResponse responseurlRe = (HttpWebResponse)requesturlRe.GetResponse();
Stream myResponseStream = responseurlRe.GetResponseStream();
resp.Content = new StreamContent(myResponseStream);
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("video/mp4");
//设置文件下载
resp.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = System.Web.HttpUtility.UrlEncode("yxt_" + dyvideomodel.aweme_id + ".mp4", System.Text.Encoding.UTF8)
};
return resp;

下载文件

原文:https://www.cnblogs.com/yutang-wangweisong/p/14344004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!