Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'memory.': 0.07; 'clean.': 0.09; 'meantime,': 0.09; 'subject:files': 0.09; 'def': 0.12; 'stored': 0.12; 'wrote': 0.14; 'mailscanner,': 0.16; 'skip:p 40': 0.19; 'memory': 0.22; 'load': 0.23; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'post': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'scanned': 0.29; 'anyone': 0.31; 'file': 0.32; 'class': 0.32; 'there.': 0.32; 'raw': 0.33; 'skip:t 40': 0.33; 'message.': 0.35; 'subject:with': 0.35; 'possible.': 0.35; 'but': 0.35; 'there': 0.35; 'believed': 0.36; 'example,': 0.37; 'too': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'dangerous': 0.60; 'viruses': 0.61; 'provide': 0.64; 'great': 0.65; 'temporary': 0.65; 'nobody': 0.68; 'dvd': 0.78; 'nagy': 0.84; 'streams': 0.84 Date: Wed, 24 Sep 2014 22:41:24 +0200 From: =?ISO-8859-1?Q?Nagy_L=E1szl=F3_Zsolt?= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Receiving large files with @tornado.web.stream_request_body References: <5422BB11.40001@shopzeus.com> <5422D5C0.8040404@shopzeus.com> In-Reply-To: <5422D5C0.8040404@shopzeus.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-shopzeus-MailScanner-Information: Please contact the ISP for more information X-shopzeus-MailScanner-ID: A359F8897398.AE4ED X-shopzeus-MailScanner: Found to be clean X-shopzeus-MailScanner-From: gandalf@shopzeus.com X-Spam-Status: No X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411591289 news.xs4all.nl 2902 [2001:888:2000:d::a6]:57402 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78312 2014.09.24. 16:31 keltezéssel, Nagy László Zsolt írta: > @tornado.web.stream_request_body >> class PostFilesHandler(tornado.web.RequestHandler): >> def post(self): >> for postfile in self.request.files: >> print("File info:",postfile) # There is no >> postfile["body"] here!!! >> >> def prepare(self): >> self.temp_file = tempfile.NamedTemporaryFile(delete=False) >> >> def data_received(self, chunk): >> self.temp_file.write(chunk) # This is great but which file is >> this??? >> >> > I have found out that the raw post data is stored there. Extracting > file contents from that raw file is possible. However, the provisional > email.contentmanager class does not provide methods for extracting > streams from a mime message. Which is bad, because nobody wants to > load a huge mime message into memory (for example, a DVD iso file...) I wrote my own solution in the meantime, that can parse any large POST request into temporary files without using too much memory. If anyone is interested I can post it here. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.