Well, I’m working my way through this book as part of my rails learnings… and hit a snag a couple of days ago that i just couldn’t understand.

I was following the file upload option where you insert the uploaded image into a database and i could not for the life of me figure out whilst my pictures were not coming back complete (they downloaded partially and then were cut off).

Getting the image properties revealled that the image was only 64KB in size, a highly suspicious number and one of those boundary numbers that programmers love to pick, so the problem had to be intentional and not just some random quirk. At first I thought it was webbrick or ruby or rails having some config setting about limiting the size of file uploads (PHP has an option to do this, although by default its much larger than 64KB)

I eventually found the problem, MySQL BLOB columns are only 64KB in size! Rails was silently filling the column with data and when it fit no more, not returning any error message.

If I hadn’t spent the last 3 years working with Oracle, then I would have probably found this earlier, BLOB’s in oracle are max out at 2GB or some such thing.

So I changed the datatype of the column to LONGBLOB, and now have oodles of space.

This helped: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

This text for google: Ruby file upload limited to 64KB with MYSQL

Commentary

  1. Espen Klem wrote on 20. Feb 2006

    I’ve been looking for an explanation of why that went wrong, so you saved me for any more problems. Thanks!

  2. Zak wrote on 28. Jun 2006

    I’ve been looking for this for a couple days now… Thank you SO much!

    -Zak

  3. dominiek wrote on 22. Jun 2007

    Encountered the same problem. But it’s kind of weird because we were using attachment_fu and specified the data column like this in the rails migration:

    addcolumn :dbfiles, :data, :binary

    Attachmentfu was giving us the 0xffff bound problems. But when we killed attachmentfu and uploaded into our own table:

    add_column :thumbnails, :data, :binary

    It did work! So maybe attachment_fu is doing some kind of weird blob magic? or maybe I should double check my story.

Leave a reply