-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream blob back to client rather than read into memory. #156
Stream blob back to client rather than read into memory. #156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very sensible to me, definitely a worthwhile addition. Thanks @darrenferguson
… into memory. - thanks Darren" This reverts commit 9aa46c6.
@Jeavon marc said you may have an issue with this and large files? Strange because we are running it in prod with some quite big files... what have you encountered? |
@darrenferguson @stevetemple We are getting OutOfMemory exceptions as well when large files (MP4 videos) are being retrieved from Azure Blob Storage (on version 1.0.2). I am assuming it may be due to the issue explained on this thread - all MP4 file being loaded to MemoryStream before writing response back to the client? |
Yes, we had to revert this change as OpenRead() will only read the first 4mb of a blob - https://stackoverflow.com/questions/6911728/cloudblob-openread-is-not-reading-all-data |
4MB is the default block size of Microsoft.WindowsAzure.Storage.Blob.CloudBlob - there is a property you can set called - StreamMinimumReadSizeInBytes. So I guess the issue lies in how Umbraco manipulates the stream. I ended up working around the issue by rewriting requests to large media files to something like this: https://gist.github.com/darrenferguson/efda4d68d535c9e4a67963bb847c042e As you can see it still returns a Stream using OpenRead() but the FileStreamResult class handles the reading of the stream in chunks and returning it to the client correctly. I'll have a dig into Umbraco and see if I can work out what it is doing. I guess it makes sense that it worked for me in some cases, as different parts of Umbraco may manipulate the stream returned from the file system provider in different ways. |
@darrenferguson ah I see, I think then that the VPP code would need to be updated to utilise the FileStreamResult |
I wouldn't think you should use a This is how the copy occurs in ASP.NET Core, I'm sure it'll be very similar in classic. So |
Was getting out of memory exceptions on large files - shouldn't need to read the whole blob into memory before returning.