0

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)

1 Answer 1

0

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. 😉

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Guy, do these functions really do what they say on the box, e.g. if I say give me bytes 1000 to 2000, will only 1000 bytes be transferred over the wire?
Yes. Unless you blow past the end of the string, in which case you'll get whatever is left.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.