Wednesday, July 4, 2018

Web Api 2: returning a stream without needing to keep everything in memory

We have an API endpoint that returns files, some of which are relatively large. We can read these (from file, database, cache) as streams, but what's the preferred approach for returning them to the caller so that we don't have to materialize the whole file in memory before returning it?

Some of our initial experiments indicate that a lot of the suggested implementations, such as this one will result in the whole file being read into memory before being returned, which can lead to quite a lot of memory being allocated on the Large Object Heap, and we'd like to avoid that.

Web Api 2: returning a stream without needing to keep everything in memory Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team