Hello, I am trying to create a cgi which downloads a pdf/tiff file from an ftpserver using ftplib. Everything works until this point. 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.
The code looks as follows: #!/usr/local/python2.1/bin/python import Path, cgi, sys, os from ftplib import FTP print "content-type: application/pdf\n\n" ftp = FTP("hostname", "salil", "passwd") try: ftp.cwd("/home/salil") except: print "Could change directory on remote server" sys.exit(1) f = open("temp.pdf", "w") ftp.retrbinary("RETR O_F.pdf", f.write) f.close() f = open("temp.pdf", "r") print f.read() 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. Thanks, Salil.
-- http://mail.python.org/mailman/listinfo/python-list