ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.38k stars 1.64k forks source link

Unable to download files larger than 250MB #1382

Closed rsandsand closed 3 years ago

rsandsand commented 3 years ago

Expected Behavior / New Feature

Ability to download large files through the Ocelot at least up to 1GB

Actual Behavior / Motivation for New Feature

When tried to download files larger than 250MB, browser saves an empty file. The response headers has Content-Length= 0 This is not an issue when file size is less than 250MB. Actual API endpoint does not have issues and has correct headers

Steps to Reproduce the Problem

  1. API with file stream [FilesController]
        [Route("{fileId}")]
        [HttpGet]
        [ProducesResponseType((int)HttpStatusCode.OK)]
        public IActionResult DownloadFile([FromRoute] FileDownloadQuery query)
        {
           var file= GetFile(query.FileId); //path to large file size > 250MB
           var stream = new FileStream(file.path, FileMode.Open,FileAccess.Read);
            return File(stream, "application/octet-stream", file.name);
        }
  2. API gateway with route configuration
    {
      "DownstreamPathTemplate": "/FileAPI/files/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": "443"
        }
      ],
      "UpstreamPathTemplate": "/files/{everything}",
      "UpstreamHttpMethod": [ "GET", "POST", "PUT", "OPTIONS" ],
      "DangerousAcceptAnyServerCertificateValidator": true
    },
  1. Call the API gate way end point https://localhost/files/F001 from browser or Postman

Specifications

CheckyChen commented 3 years ago

try change the web.config hostingModel value to outofprocess l `

`

rsandsand commented 3 years ago

Thanks this did the trick

wakm commented 3 years ago

I have the same issue and I think #1262 does too. neverthelesss changing the hostingmodel is not a satisfying solution for me. Are there any other solutions? Why is this an issue anyway?