Hello,<br><br>I am trying to create a cgi which downloads a pdf/tiff file from an ftpserver using ftplib.<br>Everything works until this point.<br>But, once the file has been retrieved, I want to be able to stream the file to the browser so that the user gets an option to save it, or open it with the necessary application. However, I am not able to figure out how this can be done.
<br><br>The code looks as follows:<br><br> #!/usr/local/python2.1/bin/python<br> <br> import Path, cgi, sys, os<br> from ftplib import FTP<br> print "content-type: application/pdf\n\n"<br>
<br> ftp = FTP("hostname", "salil", "passwd")<br> <br> try:<br> ftp.cwd("/home/salil")<br> except:<br> print "Could change directory on remote server"
<br> sys.exit(1)<br> <br> <br> f = open("temp.pdf", "w")<br> ftp.retrbinary("RETR O_F.pdf", f.write)<br> f.close()<br> f = open("temp.pdf", "r")
<br> print f.read()<br> <br> <br>I am using Apache 1.3 for this cgi. It would be great if someone can point out how this can be accomplished, or if there are any examples out there which I can refer to.<br><br>
Thanks,<br>Salil. <br> <br><br>