/// basic/download
/// <summary>
/// 压缩文件下载
/// </summary>
/// <param name="filePath "></param>
/// <returns></returns>
[HttpGet]
[ActionName("download")]
public HttpResponseMessage DownLoad(string filePath )
{
string customFileName = DateTime.Now.ToString("yyyyMMddHHmmss.rar");//客户端保存的文件名
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
HttpResponseMessage response = new HttpResponseMessage();
response.Content = new StreamContent(fileStream);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = customFileName;
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); // 这句话要告诉浏览器要下载文件
response.Content.Headers.ContentLength = new FileInfo(filePath).Length;
return response;
}