Data Too Long Error For blob Column

I am trying to upload a 432 KB exe file to a column in mysql that is type blob . It can upload pdfs and rtfs and docs and but when I try to upload even a jpg which is barely 184 kb it gives the error (data too long) why is that? (detailed error in file) :

ActiveRecord::StatementInvalid in StoragesController#create

Mysql::Error: #22001 Data too long for column 'data' at row 1: INSERT INTO `storages` (`content_type`, `name`, `updated_at`, `created_at`, `data`) VALUES('image/jpeg', 'Add Task.JPG', '2008-06-25 18:32:13', '2008-06-25 18:32:13', x'ffd8ffe000

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:in `execute' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:156:in `insert_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:291:in `insert_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:44:in `insert_without_query_dirty' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:19:in `insert' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2272:in `create_without_callbacks' c:/ruby/bin/mongrel_rails:19:in `load' c:/ruby/bin/mongrel_rails:19

Request

Parameters:

{"commit"=>"Create", "authenticity_token"=>"9cbcb635690f612dba93cfda5767036ed040ea1c", "storage"=>{"dataf"=>#<File:C:/WINDOWS/TEMP/CGI.1888.5>}}

Show session dump

It looks like you might be using MySQL "BLOB" instead of "LONGBLOB" for your binary column. Try specifying a size (large enough for your data) in your migration using the :size => option. For more detail, see the resolution of this ticket:     http://dev.rubyonrails.org/ticket/4164

Good luck!    - Eric Kramer, Nationwide Children's Hospital

...Sorry, that should have been :limit => (not :size)

Mr. Kramer,

The longblob helps to some extent ... but then I got the following error the size of the file I attempted to upload is 6948KB and the error I got was ActiveRecord::StatementInvalid in StoragesController#create

Mysql::Error: Lost connection to MySQL server during query: INSERT INTO `storages` (`content_type`, `name`, `updated_at`, `created_at`, `data`) VALUES('application/x-sdlc', 'PrintEngine_20060519_motomail_setup.exe', '2008-07-07 14:43:37

In the console I get this error :

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:471:

[BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i386-mswin32]

Any idea what could be wrong?

Eric Kramer wrote:

Check that 'max_allowed_packet' size in your MySQL config is larger than your largest file.

HTH,

Hassan Schroeder wrote:

Ather Shiraz wrote:

I am trying to upload a 432 KB exe file to a column in mysql that is type blob . It can upload pdfs and rtfs and docs and but when I try to upload even a jpg which is barely 184 kb it gives the error (data too long) why is that?

Look the /db/schema.rb file. Maybe your camp is defined as string.

I used PathTooDeep. And was very pleased with its performance. Long Path Tool is awesome to get rid on your long path files. Good luck!