Forum: Ruby on Rails send_data bombs out after 64K

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C6b37f3b86efd85450c435c9cfcab111?d=identicon&s=25 mjpowers (Guest)
on 2007-01-19 16:31
(Received via mailing list)
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])
            :filename => @document.filename,
            :type => @document.content_type,
            :stream => false)

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?

631d1677786f0725da6ccee46043686e?d=identicon&s=25 Jonathan Viney (Guest)
on 2007-01-19 16:32
(Received via mailing list)
Make sure the database column is big enough for the data. You've
got a column type that holds 64kb.

C6b37f3b86efd85450c435c9cfcab111?d=identicon&s=25 mjpowers (Guest)
on 2007-09-25 22:42
(Received via mailing list)
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

This topic is locked and can not be replied to.