# Send\_data bombs out after 64K

**URL:** <https://www.ruby-forum.com/t/send-data-bombs-out-after-64k/82525>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/send-data-bombs-out-after-64k/82525 "2007-01-19T16:31:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjpowers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mjpowers](https://www.ruby-forum.com/u/mjpowers)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/send-data-bombs-out-after-64k/82525/1 "2007-01-19T16:31:08Z")

</div>

I’m using acts\_as\_attachment plugin to store files in the database.  
Uploading works fine, but when I use send\_data to allow users to  
download them, I only get the first 64K of the stream. Here’s a  
stripped down controller:

def download\_document  
@document = Document.find(params[:id])  
send\_data(@document.attachment\_data,  
:filename =\> @document.filename,  
:type =\> @document.content\_type,  
:stream =\> false)  
end

This is how acts\_as\_attachment is set up in the document.rb model:

acts\_as\_attachment :storage =\> :db\_system,  
:max\_size =\> 516.kilobytes,  
:content\_type =\> [‘application/pdf’,  
‘application/msword’, ‘text/plain’]

I’m wondering if this is a problem in my Rails code or the server  
setup. I’m using Lighttpd/MySQL. It has no trouble with files \> 64K.  
send\_data seems to be the sticking point.

Does anyone have any suggestions about what might going on here?

Mike

---

<div class="post-metadata">

**Author:** ![mjpowers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mjpowers](https://www.ruby-forum.com/u/mjpowers)\
**Post date:** [January 19, 2007, 4:32pm UTC](https://www.ruby-forum.com/t/send-data-bombs-out-after-64k/82525/2 "2007-01-19T16:32:03Z")

</div>

Make sure the database column is big enough for the data. You’ve  
probably  
got a column type that holds 64kb.

-Jonathan.

---

<div class="post-metadata">

**Author:** ![mjpowers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mjpowers](https://www.ruby-forum.com/u/mjpowers)\
**Post date:** [September 25, 2007, 10:42pm UTC](https://www.ruby-forum.com/t/send-data-bombs-out-after-64k/82525/3 "2007-09-25T22:42:31Z")

</div>

Thanks, that was indeed the problem. MySQL limits blobs to 64K unless  
you tell it otherwise. I had this in my migration:

```
t.column "data", :binary

```

and it needed to be:

```
t.column "data", :binary, :limit => 3.megabytes

```

Mike
