Problem Statement:
I have a aspx web page which supports file upload (ie. An Attachment).
Attachment can be of size upto 500 MB.
I am able to get the HttpPostedFile But when Reading the stream to Byte[] and saving it to the database fails for bigger size files.
In NHibernateSession.Flush(), Out of Memory exception is thrown.
Note: I am able to upload upto 45MB data.
How to workaround this scenario?
You should not use
byte[]because this means that you will have to load the entire file into memory. Here’s a nice article which illustrates how you could use BLOBS withStreamsto alleviate those issues. The implementation of the custom Blob data illustrated in the article type could be found here.