zoukankan      html  css  js  c++  java
  • webapi后端返回文件流

     public HttpResponseMessage GetFileFromWebApi()

     {
      try
      {
      var FilePath = System.Web.Hosting.HostingEnvironment.MapPath(@"~/download/EditPlus64_xp85.com.zip");
      var stream = new FileStream(FilePath, FileMode.Open);
      HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
      response.Content = new StreamContent(stream);
      response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
      response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") {
      FileName="Wep Api Demo File.zip"
      };
      return response;
      }
      catch
      {
      return new HttpResponseMessage(HttpStatusCode.NoContent);
      }
     }
  • 相关阅读:
    二分法排序
    GDB调试命令
    X264编译
    ffmpeg编译
    css-icons
    Javascript组成--ECMAScript,DOM,BOM
    9 Utils
    8 移动端填坑
    7 媒体查询( Media Queries )
    css3--rem
  • 原文地址:https://www.cnblogs.com/DSC1991/p/15252339.html
Copyright © 2011-2022 走看看