Advait Bellur wrote:> HI,
>
> I need to know how to download any file using send_file() method.The
> code I have shown below is for a specific file........how ever I need it
> for any file.
>
>
> THE CODE
> ........
>
> def download_files
>
> send_file(''D:/hr/Handbook.doc'',
> :filename => params[:filename] ,
> :type =>
''application/octet-stream'',
> :disposition => ''attachment'',
> :stream => true,
> :buffer_size => ''4096'')
>
> end
>
> D:/hr/Handbook.doc is the particular file address, I need to specify an
> address that downloads any file when the respective link is clicked.
do something like this first u need to find the file
def download
@document = Document.find(params[:id])
send_file(@document.full_filename,
:filename => @document.filename,
:type => @document.content_type,
:disposition => ''attachment'')
end
hope this helps
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---