I have a very simple python script to download a jpg image to client, but it always return a broken image.
Really don't know what's missing. Can anyone help?
Here is the code:
filename = r"path\\image.jpg"
sys.stdout.write( "Content-Disposition: attachment; filename=image.jpg\\r\
+ "Content-Type: image/jpeg\\r\
Here are the images on the server and downloaded:
Your carriage returns look Windowsy to me; are you using Windows? If so, this might explain what's going on:
so even though you're reading a binary file using "rb", you're writing a text file when using stdout, even with the attempt at setting MIME type.