I am in the process of replacing a basic file serving API call which looks like this:
return Results.File("myfile.pdf", MediaTypeNames.Application.Pdf, enableRangeProcessing: true);
If I store "myfile.pdf" as a byte array (AKA string?) in Redis, how can I later serve the file in a similar as I currently am?
Does Redis have the ability to return a string as a stream, and if it does, do range requests on that stream work as expected? (only transferring the minimum bytes required to fulfil the range request)
You can't stream as such, but you can read the contents of the string in chunks using the StringLength
and StringGetRange
methods in StackExchange.Redis.
Wrapping this is a stream wouldn't be a terribly difficult exercise. And, honestly, if you're so inclined, wouldn't be a terrible open-source project. 😉