Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/tornado_handlers/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,18 @@ def prepare(self):
int(self.get_argument('expected_size')))
try:
total = int(self.request.headers.get("Content-Length", "0"))
except KeyError:
total = 0
except (KeyError, ValueError):
total = 0
# Set max body size based on Content-Length or expected_size parameter
if 'expected_size' in self.request.arguments:
max_size = int(self.get_argument('expected_size'))
elif total > 0:
# Add 10% buffer for multipart overhead
max_size = int(total * 1.1)
else:
# Default to 500MB if no size info available
max_size = 500 * 1024 * 1024
self.request.connection.set_max_body_size(max_size)
self.multipart_streamer = MultiPartStreamer(total)

def data_received(self, chunk):
Expand Down Expand Up @@ -344,4 +354,3 @@ def post(self, *args, **kwargs):

finally:
self.multipart_streamer.release_parts()