Topic: Sending file - Need help

Need Help with sending a fileI have a nav_bar with a link_to_remote that brings up a partial with option to download a file.Used send_data and send_file in the controller to allow users to download a file.I expected something to occur letting me know I am about to receive a file or have received a file on the browser.  Nothing happened.

Here is the send_data code:  def download   

def download<br>
    puts ' --------------------- '
    puts ' ** download Begin  ** '
    puts ' --------------------- '
    <br>
        send_file("#{RAILS_ROOT}/files/download/PCCFI-Vendor-Form.pdf", :filename => "Vendor-Form.pdf", :type => "application/pdf", :disposition => "attachment")
    <br>
    puts ' ------------------- '
    puts ' ** download End  ** '
    puts ' ------------------- '
    <br>
  end

Server results:
---------------------
** download Begin  **
---------------------
-------------------
** download End  **
-------------------
e/form]


Processing WebpageController#download (for 127.0.0.1 at 2010-07-21 15:27:53) [PO
ST]
  Parameters: {"authenticity_token"=>"e70f56d9f8164006fb34a12f694d3fdb32087f70"}

  ←[4;36;1mSQL (0.0ms)←[0m   ←[0;1mSET NAMES 'utf8'←[0m
  ←[4;35;1mSQL (1.0ms)←[0m   ←[0mSET SQL_AUTO_IS_NULL=0←[0m
Sending data Vendor-Form.pdf
Completed in 7ms (View: 0, DB: 1) | 200 OK [http://localhost/webpage/download]

Screen result:

This pops up on the partial part of the webpage:

C:/rails-clubs/clublist-dev/files/download/PCCFI-Vendor-Form.pdf

Here is the send_file code:

  def download
    puts ' --------------------- '
    puts ' ** download Begin  ** '
    puts ' --------------------- '
   
        send_file("#{RAILS_ROOT}/files/download/PCCFI-Vendor-Form.pdf", :filename => "Vendor-Form.pdf", :type => "application/pdf", :disposition => "attachment")
   
    puts ' ------------------- '
    puts ' ** download End  ** '
    puts ' ------------------- '
   
  end   

Server results:
---------------------
** download Begin  **
---------------------
-------------------
** download End  **
-------------------
e/form]


Processing WebpageController#download (for 127.0.0.1 at 2010-07-21 15:31:09) [PO
ST]
  Parameters: {"authenticity_token"=>"e70f56d9f8164006fb34a12f694d3fdb32087f70"}

  ←[4;36;1mSQL (0.0ms)←[0m   ←[0;1mSET NAMES 'utf8'←[0m
  ←[4;35;1mSQL (0.0ms)←[0m   ←[0mSET SQL_AUTO_IS_NULL=0←[0m
Completed in 16ms (View: 0, DB: 0) | 200 OK [http://localhost/webpage/download]
Streaming file C:/rails-clubs/clublist-dev/files/download/PCCFI-Vendor-Form.pdf

Screen result:

This pops up on the partial part of the webpage:

%PDF-1.6 %�� 159 0 obj <> endobj 169 0 obj <</DECODEPARMS<< 4 12 Predictor Columns>>/Filter/FlateDecode/ID[]/Index[159 25]/Info 158 0 R/Length 65/Prev 58351/Root 160 0 R/Size 184/Type/XRef/W[1 2 1]>>stream h�bd ``b`� �@�� H��� ��d ܭ %!@�  #� ��H.� @�

Can anyone give me a good example of how to write the code or if there is a requirement that I am missing?

Last edited by freeoxegen (2010-07-21 16:13:21)