by Michael Hill >> Fri, 6 May 2005 4:35:00 GMT
Here a fun question for a Friday afternoon.
We have an attachment screen by which you can select any type of file and we want to save it as a BLOB in the database.
It was originally written using a transient object to temporarily store the object before it was written to the database. This was fine for files that are small, but when I tried to load a 3MB file it threw a 1018 exception, which I know it to do with the size of certain buffers. I know I can change the size of the buffers so that this doesn't happen but the question then becomes what size do I make the buffers, since the number of users that couple be attaching documents is 1..n.
Looking at the code I've decided it doesn't actually need to load the file temporarily into the transient, because it doesn't do anything with it until it saves it. So now I'm passing the readBinary straight to the save of the persistent object. I have noticed doing it this way has allowed us to store larger files (at least 34MB) before the same 1018 error message appears. Now I back with the same issue that I was having with transients about what size to make the buffers.
All we are really doing is just using the database to store the object and nothing else. I suspect that we will have the same problem when we restore the object back to disk.
Is there anyway of doing this without having to change the size of the buffers, as the size of the file will not be known till we try to save it?
Any other suggestions?
Cheers