ruby mysql blob

Recently, one of mycert’s internal project required that PDF files to be saved into the database (MyQL). Since its is not easy to find the sample code via Google,  here’s a quick note for future reference.

Another thing is that the max file size for blob is 64k. To store more than that, one need to use ‘longblob’. Not sure what is the max size for this type. Otherwise, your binary just been truncated by mysql without any warning (I spend quite some time debugging the code before realizing this. Happy trying!

Leave a Reply

Your email address will not be published. Required fields are marked *