Posting gzip'd image file - server says Malformed Upload?

Chris Angelico rosuav at gmail.com
Wed Jun 17 20:23:26 EDT 2015


On Thu, Jun 18, 2015 at 7:55 AM, Paul Hubert <phbrt25 at gmail.com> wrote:
> f_in = open(dafile, 'rb')
> f_out = gzip.open('/Users/Paul/Desktop/scripts/pic.jpg.gz', 'wb')
> f_out.writelines(f_in)
> f_out.close()
> f_in.close()

Are you sure you want iteration and writelines() here? I would be
inclined to avoid those for any situation that isn't plain text. If
the file isn't too big, I'd just read it all in a single blob and then
write it all out at once.

ChrisA



More information about the Python-list mailing list