Sulu Media Manager: per-MIME-type upload size constraint absent from admin UI
0 reputation · 28 Dec 2020, 02:02 UTC
0 reputation · 28 Dec 2020, 02:02 UTC
Sulu's Media Manager relies on a single upload_max_filesize directive from PHP configuration, currently defaulting to 2 MiB, without a mechanism to impose distinct limits based on MIME type. This design means that all file categories—images, videos, documents, archives—share the same ceiling, and the application only validates size after the complete payload has been received by the server. As a result, uploads exceeding the threshold consume network and disk resources before triggering a generic error, creating a potential bottleneck when multiple editors submit large assets concurrently. The admin UI provides no per‑type override, leaving administrators dependent on server‑level php.ini or .user.ini adjustments, which carry site‑wide implications and may conflict with other PHP applications hosted in the same environment.
No, Sulu Media Manager cannot enforce independent upload size limits per MIME type without modifying global PHP settings, because its validation layer relies on the server-level upload_max_filesize directive and does not intercept file size before the full payload arrives, meaning all file categories share a single ceiling defaulting to 2 MiB.
The likely explanation is that the application layer lacks a pre-receive hook to validate size based on MIME classification; the confirmed fact is that the current design enforces a uniform PHP limit, causing oversized uploads to consume network and disk resources before triggering a generic error.
.user.ini or web server directives (Nginx client_max_body_size, Apache LimitRequestBody) to scoped limits that override the PHP default for the Sulu document root.upload_max_filesize to accommodate the largest legitimate asset, then supplement with application-level checks or Sulu-specific bundles to enforce stricter per-type caps for other categories.Under concurrent upload loads, a single global limit can create contention; scoped web server limits reduce cross-application interference but may still bottleneck if the PHP process count is saturated. Application-level validation after receive avoids premature errors but does not prevent resource consumption.
To determine whether a scoped web server directive or a global PHP adjustment is the appropriate starting point, please specify whether the deployment allows per-directory .user.ini overrides or requires a global php.ini change.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 28 Dec 2020, 12:37 UTC
A per‑MIME‑type UI setting in Sulu can only restrict uploads below PHP’s existing ceiling; it cannot raise it. PHP enforces upload_max_filesize and post_max_size before Symfony or Sulu receives the request, so a 10 MiB video fails at the web/PHP layer even if Sulu’s admin allows videos up to 50 MiB. To support type‑specific limits, set the global PHP limit to the largest expected type, then apply tighter MIME‑type checks in Sulu’s upload handler or a custom Symfony validator after the file lands in the temporary directory. Verify current limits with php -i or phpinfo(), then attempt an upload just above that value to confirm rejection occurs before application logic. This assumes a standard Sulu 2.x / Symfony stack and should be confirmed against the deployed version.