From fede8c997529a3bcd9718a331e74597d7070f644 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 10 Jan 2024 13:44:00 +0100 Subject: [PATCH] :sparkles: Setup better media max file-size on devenv --- backend/scripts/repl | 4 ++++ backend/scripts/start-dev | 3 +++ backend/src/app/config.clj | 2 ++ backend/src/app/media.clj | 18 ++++++++---------- docker/devenv/files/nginx.conf | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/backend/scripts/repl b/backend/scripts/repl index e2cd441c0..2a89163a5 100755 --- a/backend/scripts/repl +++ b/backend/scripts/repl @@ -32,6 +32,10 @@ export PENPOT_FLAGS="\ disable-soft-file-schema-validation \ disable-soft-file-validation"; + +# Setup default upload media file size to 100MiB +export PENPOT_MEDIA_MAX_FILE_SIZE=104857600 + # export PENPOT_DATABASE_URI="postgresql://172.17.0.1:5432/penpot" # export PENPOT_DATABASE_USERNAME="penpot" # export PENPOT_DATABASE_PASSWORD="penpot" diff --git a/backend/scripts/start-dev b/backend/scripts/start-dev index 59a8a189b..8dafad250 100755 --- a/backend/scripts/start-dev +++ b/backend/scripts/start-dev @@ -34,6 +34,9 @@ export OPTIONS=" -J-XX:+UnlockDiagnosticVMOptions \ -J-XX:+DebugNonSafepoints" +# Setup default upload media file size to 100MiB +export PENPOT_MEDIA_MAX_FILE_SIZE=104857600 + # Setup HEAP # export OPTIONS="$OPTIONS -J-Xms50m -J-Xmx1024m" # export OPTIONS="$OPTIONS -J-Xms1100m -J-Xmx1100m -J-XX:+AlwaysPreTouch" diff --git a/backend/src/app/config.clj b/backend/src/app/config.clj index ef021d7c1..b4fe60c65 100644 --- a/backend/src/app/config.clj +++ b/backend/src/app/config.clj @@ -79,6 +79,8 @@ :telemetry-uri "https://telemetry.penpot.app/" + :media-max-file-size (* 1024 1024 30) ; 30MiB + :ldap-user-query "(|(uid=:username)(mail=:username))" :ldap-attrs-username "uid" :ldap-attrs-email "mail" diff --git a/backend/src/app/media.clj b/backend/src/app/media.clj index a9a559e5b..8d2315352 100644 --- a/backend/src/app/media.clj +++ b/backend/src/app/media.clj @@ -32,9 +32,6 @@ org.im4java.core.IMOperation org.im4java.core.Info)) -(def default-max-file-size - (* 1024 1024 30)) ; 30 MiB - (s/def ::path fs/path?) (s/def ::filename string?) (s/def ::size integer?) @@ -83,13 +80,14 @@ (defn validate-media-size! [upload] - (when (> (:size upload) (cf/get :media-max-file-size default-max-file-size)) - (ex/raise :type :restriction - :code :media-max-file-size-reached - :hint (str/ffmt "the uploaded file size % is greater than the maximum %" - (:size upload) - default-max-file-size))) - upload) + (let [max-size (cf/get :media-max-file-size)] + (when (> (:size upload) max-size) + (ex/raise :type :restriction + :code :media-max-file-size-reached + :hint (str/ffmt "the uploaded file size % is greater than the maximum %" + (:size upload) + max-size))) + upload)) (defmulti process :cmd) (defmulti process-error class) diff --git a/docker/devenv/files/nginx.conf b/docker/devenv/files/nginx.conf index ab2c5ea6e..d291512c8 100644 --- a/docker/devenv/files/nginx.conf +++ b/docker/devenv/files/nginx.conf @@ -49,7 +49,7 @@ http { listen 3449 default_server; server_name _; - client_max_body_size 30M; + client_max_body_size 100M; charset utf-8; proxy_http_version 1.1;