title: Upload files with @tornado.web.stream_request_body
body: <p>I'm trying to use <strong><em>@tornado.web.stream_request_body</em></strong> for upload files.</p>
  
  <p>But I have a problem with upload large files. 
  For example, when I upload PDF file larger than 100 MB (<a href="https://yadi.sk/i/rzLQ96pk3Tcef6" rel="nofollow noreferrer">https://yadi.sk/i/rzLQ96pk3Tcef6</a>) it loads incorrectly and it doesn't open in viewers.</p>
  
  <p>Code example:</p>
  
  <pre><code>MAX_STREAMED_SIZE = 1024 * 1024 * 1024
  
  @tornado.web.stream_request_body
  class UploadHandler(tornado.web.RequestHandler):
      def prepare(self):
         self.request.connection.set_max_body_size(MAX_STREAMED_SIZE)
         self.f = open(os.path.join('files', '12322.pdf'), "w+b")
  
      def data_received(self, data):
         self.f.write(data)
  
      def post(self):
         self.f.close()
         print("upload completed")
  </code></pre>
  
  <p>What can be the reason of the problem?</p>