[python-win32] Binary data in ASP

Emlyn Jones emlynj at gmail.com
Tue Apr 26 10:47:16 CEST 2005


Hello,
I am trying to get an ASP script to download a file. The file arrives at the
correct size but is corrupted, what am I missing?
If I run the get_file function directly at the command prompt and save the
resulting data it is fine, so there must be something wrong with the way I send
the data from the browser?

If have this code in the asp page:
<%
...
filename,data = get_file(file_path)
Response.AddHeader("content-disposition","attachment; filename=%s" %
(filename,))
Response.ContentType="application/zip"
Response.BinaryWrite(buffer(data))
%>

the get_file function just does this:

def get_file(path):
   file = open(path,"rb")
   data = file.read()
   file.close()
   return os.path.split(path)[1],data

Any pointers will be greatfully recieved.

Thanks,
Emlyn.


More information about the Python-win32 mailing list