From 8b08b03fbfe14a6daa2771f11faaac8d265e41b6 Mon Sep 17 00:00:00 2001 From: Arksine Date: Fri, 11 Sep 2020 06:27:48 -0400 Subject: [PATCH] app: add max_upload_size configuration option Signed-off-by: Eric Callahan --- docs/installation.md | 2 ++ moonraker/app.py | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 383fa9e..bc8c0c4 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -154,6 +154,8 @@ port: 7125 klippy_address: /tmp/klippy_uds # The address of Unix Domain Socket used to communicate with Klippy. Default # is /tmp/klippy_uds +max_upload_size: 200 +# The maximum size allowed for a file upload. Default is 200 MiB. enable_debug_logging: True # When set to True Moonraker will log in verbose mode. During this stage # of development the default is True. In the future this will change. diff --git a/moonraker/app.py b/moonraker/app.py index 652e778..dc96083 100644 --- a/moonraker/app.py +++ b/moonraker/app.py @@ -16,9 +16,6 @@ from websockets import WebsocketManager, WebSocket from authorization import AuthorizedRequestHandler, AuthorizedFileHandler from authorization import Authorization -# Max Upload Size of 200MB -MAX_UPLOAD_SIZE = 200 * 1024 * 1024 - # These endpoints are reserved for klippy/server communication only and are # not exposed via http or the websocket RESERVED_ENDPOINTS = [ @@ -99,6 +96,8 @@ class MoonrakerApp: self.tornado_server = None self.api_cache = {} self.registered_base_handlers = [] + self.max_upload_size = config.getint('max_upload_size', 200) + self.max_upload_size *= 1024 * 1024 # Set Up Websocket and Authorization Managers self.wsm = WebsocketManager(self.server) @@ -107,7 +106,6 @@ class MoonrakerApp: mimetypes.add_type('text/plain', '.log') mimetypes.add_type('text/plain', '.gcode') mimetypes.add_type('text/plain', '.cfg') - debug = config.getboolean('enable_debug_logging', True) enable_cors = config.getboolean('enable_cors', False) @@ -135,7 +133,7 @@ class MoonrakerApp: def listen(self, host, port): self.tornado_server = self.app.listen( - port, address=host, max_body_size=MAX_UPLOAD_SIZE, + port, address=host, max_body_size=self.max_upload_size, xheaders=True) async def close(self):