从WebAPI返回大文件-算术运算中的上溢或下溢

时间:2018-11-27 18:28:12

标签: c# asp.net .net asp.net-mvc asp.net-web-api2

  [Route("bulk_download")]
    public IHttpActionResult GetDownloadFilesAsync(string Ids)
    {
        try
        {
            var file_path = "c:/file_path/file.zip"; //I have a function which saves file to temp folder and returns the path 
            var file_data = FileHelper.ReadFile(file_path);
            bool is_deleted = FileHelper.DeleteFile(file_path);
            if (!is_deleted)
            {
                SlackClient.PostMessage("ERROR : couldn't delete file : " + file_path);
            }
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new ByteArrayContent(file_data);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = "download.zip";
            return ResponseMessage(response);
        }
        catch (Exception ex)
        {
            return InternalServerError();
        }
    }

我有一个需要发回2 GB zip文件的要求。

错误文字:算术运算中上溢或下溢

注意:1 GB数据可以正常工作。

...

0 个答案:

没有答案