Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cajuncoding/38c08dfedf3f521e53cf41ab9d53d182 to your computer and use it in GitHub Desktop.
Save cajuncoding/38c08dfedf3f521e53cf41ab9d53d182 to your computer and use it in GitHub Desktop.
Flurl Extensions for Downloading Binary Data for easy Deferred streaming as AsyncEnumerable streams.
//WIP: This is an extension method for Flurl to download a Binary file direcctly into an AsyncEnumerable that that
// can then be iterated with deferred execution for streaming binary data without downloading all data into Memory OR
// needing to store in an intermediate location.
//TODO:
// - Implement IAsyncEnumerable wrapper for the Stream Reading which can then be easily chunked via Linq just as it currently is...
// - This method may run a quick HTTP GET for headers Only to check and confirm existence, and then return an AsynEnumerable wrapper with an internal Delegate that creates the Stream
// reads the bytes in buffer/chunk sizes until Zero bytes are read; this would occur inside the GetEnumerator() call...
// - Develop this as an Open Source (e.g. Gist) Flurl Extension method for Re-use and sharing!
// - Reference Flurl's DownloadFileAsync for getting a true Async stream (would happen in the Delegate when IAsyncEnumerable.GetEnumerator() is called...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment