Data Too Long Error For blob Column

55 views
Skip to first unread message

Ather Shiraz

unread,
Jun 25, 2008, 6:42:11 PM6/25/08
to rubyonra...@googlegroups.com
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

---
:user_id: 1
:expires_at: 2008-06-25 19:02:13.073000 -04:00
flash: !map:ActionController::Flash::FlashHash {}

:csrf_id: bd7cdb1ca1cd0f1236cac45fbc63424b

Response

Headers:

{"cookie"=>[],
"Cache-Control"=>"no-cache"}

Attachments:
http://www.ruby-forum.com/attachment/2252/error_ful.txt

--
Posted via http://www.ruby-forum.com/.

Eric Kramer

unread,
Jul 7, 2008, 1:45:14 PM7/7/08
to Ruby on Rails: Talk
...Sorry, that should have been :limit => (not :size)

On Jun 25, 6:42 pm, Ather Shiraz <rails-mailing-l...@andreas-s.net>
wrote:

Eric Kramer

unread,
Jul 7, 2008, 1:42:24 PM7/7/08
to Ruby on Rails: Talk
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

On Jun 25, 6:42 pm, Ather Shiraz <rails-mailing-l...@andreas-s.net>
wrote:

Ather Shiraz

unread,
Jul 7, 2008, 2:47:16 PM7/7/08
to rubyonra...@googlegroups.com
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:
> 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
>
> On Jun 25, 6:42 pm, Ather Shiraz <rails-mailing-l...@andreas-s.net>

--
Posted via http://www.ruby-forum.com/.

Hassan Schroeder

unread,
Jul 7, 2008, 4:45:12 PM7/7/08
to rubyonra...@googlegroups.com
On Mon, Jul 7, 2008 at 11:47 AM, Ather Shiraz
<rails-mai...@andreas-s.net> wrote:

> 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:

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

HTH,
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com

Ather Shiraz

unread,
Jul 8, 2008, 4:48:30 PM7/8/08
to rubyonra...@googlegroups.com

Where is this max_allowed_packet field in mysql config? I am using MYSQL
5.0 and there is my.ini file which does not have that field however
my-huge.ini under c:\program files\mysql\mysql server 5.0\my.ini

Fernando Caicedo

unread,
Jan 15, 2009, 12:35:50 AM1/15/09
to rubyonra...@googlegroups.com
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.

Alexis Ja

unread,
Feb 27, 2014, 4:32:34 AM2/27/14
to rubyonra...@googlegroups.com
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!
Reply all
Reply to author
Forward
0 new messages