Page 1 of 1

Storing large binaries into the database

Posted: Mon Apr 12, 2010 7:33 pm
by itopcin
Hi there,

I've had this problem before, and today it came up again to haunt me once more :)
I have to load a big file into the database, but I keep getting a 1018 (no memory for buffers exception) whenever the file is bigger than the transient or persistent cache size.

I've already tried to read the file in chunks and assign the small bits to my object's binary property, but I still get the same exception (which is understandable, given that jade has to keep it in memory before the transaction is committed / rolled back). PS: The property type is Binary, and the object is a persistent object.

So, the question is: is there a solution for that?

Thanks!
Igor

Re: Storing large binaries into the database

Posted: Mon Apr 12, 2010 8:42 pm
by kevinnz
Hi

Have you check out the JadeBytes class? That may well do what you need.

Kevin

Re: Storing large binaries into the database

Posted: Tue Apr 13, 2010 12:36 am
by itopcin
Thanks Kevin, that worked pretty well.
I simply used JadeBytes::loadFromFile and JadeBytes::extractFromFile. All the hard work was done by Jade :)

Cheers
Igor

Re: Storing large binaries into the database

Posted: Tue Apr 13, 2010 8:24 am
by allistar
A solution to this problem without using JadeBytes is to use multiple objects to represent the binary, each object getting, say, 5Mb of the binary each.