码迷,mamicode.com
首页 > 其他好文 > 详细

下载文件

时间:2021-01-30 11:41:21      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:res   value   use   mac   header   iphone   pos   isp   apn   

 

//添加地址

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;

下载文件

标签:res   value   use   mac   header   iphone   pos   isp   apn   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!