Quick send_data question

Hi,

I am using send_data to allow users to download files from the database
but ran into a small problem, it seems that files upload fine but when
they download only 64kb of the file is sent.

I’m using the basic rails code from the Agile book:

#upload code in my sheet model

def file=(document_field)
self.filename = base_part_of(document_field.original_filename)
self.content_type = document_field.content_type.chomp
self.data = document_field.read
end

def base_part_of(file_name)
name = File.basename(file_name)
name.gsub(/[^\w._-]/, ‘’)
end

#download in my application controller

def download
sheet = params[:id]
@sheet = Sheet.find(sheet)
send_data(@sheet.data, :type => @sheet.content_type, :filename =>
@sheet.filename)
end

Am I just completely missing something?

What DB are you using? Maybe there’s a (time or data) limit in your
DB-Configuration?

Daniel J. wrote:

What DB are you using? Maybe there’s a (time or data) limit in your
DB-Configuration?

Im using MySQL on Dreamhost. Do they limit uploads?

Daniel J. wrote:

What DB are you using? Maybe there’s a (time or data) limit in your
DB-Configuration?

It seems that only 64kb of the file is uploaded to the database, is the
rails code at fault here? I would assume that it gets cut off somewhere,
being that 3 files I uploaded that are all different sizes sit in the
database at 64kb.

Thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs