I don''t know why this isn''t working. If I download a word doc that I uploaded, all I get is the S3 file path in the document. If I access the s3 file path directly in my browser, it downloads the file correctly. Here is my controller method: def download @curriculum = @school.curriculums.find(params[:id]) send_data @curriculum.attachment.public_filename, :filename => @curriculum.attachment.filename, :type => @curriculum.attachment.content_type end view: link_to curriculum.attachment.filename.split(''.'').first, :action => ''download'', :id => curriculum.id The file is downloaded, but not the file content. Thanks for any help! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Bleigh
2007-Dec-18 20:14 UTC
Re: attachment_fu and S3 -- cannot download file correctly
you are trying to call send_data which will send a string to the browser, so you are just sending the string of the url. try this: def download @curriculum = @school.curriculums.find(params[:id]) redirect_to @curriculum.public_filename end On Dec 18, 2007, at 2:39 PM, jko170 wrote:> > I don''t know why this isn''t working. If I download a word doc that I > uploaded, all I get is the S3 file path in the document. If I access > the s3 file path directly in my browser, it downloads the file > correctly. > > Here is my controller method: > > def download > @curriculum = @school.curriculums.find(params[:id]) > send_data @curriculum.attachment.public_filename, > :filename => @curriculum.attachment.filename, > :type => @curriculum.attachment.content_type > end > > view: > > link_to curriculum.attachment.filename.split(''.'').first, :action => > ''download'', :id => curriculum.id > > The file is downloaded, but not the file content. Thanks for any help! > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That worked! Thanks a lot. On Dec 18, 2:14 pm, Michael Bleigh <mble...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you are trying to call send_data which will send a string to the > browser, so you are just sending the string of the url. try this: > > def download > @curriculum = @school.curriculums.find(params[:id]) > redirect_to @curriculum.public_filename > end > > On Dec 18, 2007, at 2:39 PM, jko170 wrote: > > > > > I don''t know why this isn''t working. If I download a word doc that I > > uploaded, all I get is the S3 file path in the document. If I access > > the s3 file path directly in my browser, it downloads the file > > correctly. > > > Here is my controller method: > > > def download > > @curriculum = @school.curriculums.find(params[:id]) > > send_data @curriculum.attachment.public_filename, > > :filename => @curriculum.attachment.filename, > > :type => @curriculum.attachment.content_type > > end > > > view: > > > link_to curriculum.attachment.filename.split(''.'').first, :action => > > ''download'', :id => curriculum.id > > > The file is downloaded, but not the file content. Thanks for any help!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---