Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92828
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:file': 0.07; "'rb')": 0.09; 'here?': 0.09; 'subject:Posting': 0.09; 'cc:addr :python-list': 0.10; 'wed,': 0.15; 'thu,': 0.15; 'big,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'iteration': 0.16; 'skip:g 50': 0.16; 'subject:image': 0.16; 'subject:server': 0.16; 'sure.': 0.16; 'wrote:': 0.16; 'typical': 0.18; '(or': 0.21; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'am,': 0.23; 'fit': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; 'chris': 0.26; 'plain': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'once.': 0.29; "i'd": 0.31; 'subject:?': 0.34; 'file': 0.34; 'received:google.com': 0.34; 'text.': 0.35; "isn't": 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'done.': 0.37; 'pm,': 0.39; 'sure': 0.40; 'avoid': 0.61; 'situation': 0.67; 'blob': 0.84; 'chrisa': 0.84; 'meg': 0.84; 'to:none': 0.90 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ZK/gS6LHME9eMdTuOOqCwRH7qpaEWzvGYhKVlK7aeug=; b=UhXeF3zFqC0gS0K/Z/T21cat5+E2u4dGyVutkRznGaGFwZLnsdzsBFgNcRJ5Z71N5a DZ9jXI64OyPEzdPv7s4nFxt3oWeKThMfFUEROWXhVUr+hxW9O0M56bUtNtAKoD5EXu5n sdhn5l2alaxaON0ikhWHm3AliW1KYjDYqEkptBDstXAifGkGv82WTuD8femerLVvScUF KsMfKRssg5Ue9NCdpLelE4McVofqUpkC5UdduEJO1FrniSbBbGkbWG4FvAGz9RD0sLRu 4HTs6DsauRhjmkPlnMNmjS8RhyQ+QtcXbk6thJ17220ndAeMxZ47cXQDL1AxO+odCYc0 d+AA== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.141.164 with SMTP id rp4mr42270688igb.2.1434631348985; Thu, 18 Jun 2015 05:42:28 -0700 (PDT) |
| In-Reply-To | <1434631131.4121351.298941169.05993FA2@webmail.messagingengine.com> |
| References | <59756062-6632-46b4-a92c-aa3a260718a7@googlegroups.com> <CAPTjJmoSYqRyWNj4pQ14e16qRvx+B+xo3qvHfZATxkg=iEC7KA@mail.gmail.com> <1434631131.4121351.298941169.05993FA2@webmail.messagingengine.com> |
| Date | Thu, 18 Jun 2015 22:42:28 +1000 |
| Subject | Re: Posting gzip'd image file - server says Malformed Upload? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.600.1434631351.13271.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1434631351 news.xs4all.nl 2933 [2001:888:2000:d::a6]:33755 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:92828 |
Show key headers only | View raw
On Thu, Jun 18, 2015 at 10:38 PM, <random832@fastmail.us> wrote:
> On Wed, Jun 17, 2015, at 20:23, Chris Angelico wrote:
>> On Thu, Jun 18, 2015 at 7:55 AM, Paul Hubert <phbrt25@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.
>
> Is there a reason not to use shutil.copyfileobj?
If the file is too big (or might be too big) to want to fit into
memory, then sure. But a typical JPEG image isn't going to be
gigabytes of content; chances are it's going to be a meg or so at
most, and that doesn't justify the overhead of chunking. Just read it,
write it, job done.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Posting gzip'd image file - server says Malformed Upload? Paul Hubert <phbrt25@gmail.com> - 2015-06-17 14:55 -0700
Re: Posting gzip'd image file - server says Malformed Upload? Chris Angelico <rosuav@gmail.com> - 2015-06-18 10:23 +1000
Re: Posting gzip'd image file - server says Malformed Upload? Paul Hubert <phbrt25@gmail.com> - 2015-06-17 17:45 -0700
Re: Posting gzip'd image file - server says Malformed Upload? Michael Torrie <torriem@gmail.com> - 2015-06-17 19:10 -0600
Re: Posting gzip'd image file - server says Malformed Upload? Chris Angelico <rosuav@gmail.com> - 2015-06-18 11:46 +1000
Re: Posting gzip'd image file - server says Malformed Upload? Paul Hubert <phbrt25@gmail.com> - 2015-06-17 20:48 -0700
Re: Posting gzip'd image file - server says Malformed Upload? Chris Angelico <rosuav@gmail.com> - 2015-06-18 13:56 +1000
Re: Posting gzip'd image file - server says Malformed Upload? Michael Torrie <torriem@gmail.com> - 2015-06-17 21:59 -0600
Re: Posting gzip'd image file - server says Malformed Upload? Laura Creighton <lac@openend.se> - 2015-06-18 23:44 +0200
Re: Posting gzip'd image file - server says Malformed Upload? random832@fastmail.us - 2015-06-18 08:38 -0400
Re: Posting gzip'd image file - server says Malformed Upload? Chris Angelico <rosuav@gmail.com> - 2015-06-18 22:42 +1000
csiph-web