# Save data to blob

**URL:** <https://www.ruby-forum.com/t/save-data-to-blob/69394>\
**Category:** Rails\
**Created:** [September 20, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/save-data-to-blob/69394 "2006-09-20T19:09:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [September 20, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/save-data-to-blob/69394/1 "2006-09-20T19:09:18Z")

</div>

Hi, folks,

I have a “data” field that is defined as “blob” in model file. However,  
it always fails when I try to save a larger file … in this case, the  
so-called larger is merely 200K around. Do I need to do anything  
special to be able to save it (the file can be text or binary).

Mysql::Error: #22001Data too long for column ‘data’ at row 1: INSERT  
INTO works (`name`, `tag_id`, `data`, `email`) VALUES(‘test102’, 0,  
x’255044462d…

Thanks

Oliver

---

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [September 20, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/save-data-to-blob/69394/2 "2006-09-20T19:17:19Z")

</div>

On 2006-09-20, at 14:03 , Oliver wrote:

> I have a “data” field that is defined as “blob” in model file.  
> However,  
> it always fails when I try to save a larger file … in this case, the  
> so-called larger is merely 200K around. Do I need to do anything  
> special to be able to save it (the file can be text or binary).

Blobs are way too much trouble to deal with. Any reason why you can’t  
store the blobby data in an external file?

---

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [September 20, 2006, 7:37pm UTC](https://www.ruby-forum.com/t/save-data-to-blob/69394/3 "2006-09-20T19:37:22Z")

</div>

hmm … I suppose it can be external file, since I am new to rails. I  
just thought with ActiveRecord in the middle, I could deal with all  
fields in a uniform way.

Is storing external file a more recommended practice? then the  
directory layout and naming become an issue to deal with when you have  
many files. Any pointer on how is it supposed to be done?

Thanks for the reply.

Oliver

---

<div class="post-metadata">

**Author:** ![oliver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oliver](https://www.ruby-forum.com/u/oliver)\
**Post date:** [September 20, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/save-data-to-blob/69394/4 "2006-09-20T20:45:39Z")

</div>

On 2006-09-20, at 14:29 , Oliver wrote:

> Is storing external file a more recommended practice? then the  
> directory layout and naming become an issue to deal with when you have  
> many files. Any pointer on how is it supposed to be done?

There’s a plugin called file\_column.

Sorry I can’t give you more details, I have no experience with it,  
for I’ve been using my own solution since before file\_column was  
around. (and my own solution is not ready for public consumption,  
otherwise I’d gladly recommend it)
