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
on 2007-01-19 16:31
on 2007-01-19 16:32
Make sure the database column is big enough for the data. You've probably got a column type that holds 64kb. -Jonathan.
on 2007-09-25 22:42
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