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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Make sure the database column is big enough for the data. You''ve probably got a column type that holds 64kb. -Jonathan. On 1/12/07, mjpowers <mpowers1-ee4meeAH724@public.gmane.org> wrote:> > > 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 > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---