JSON-RPC methods can now receive file uploads over multipart/form-data, alongside their structured parameters, in a single call. Opt-in and off by default; with the feature off, behaviour is identical to 5.1.
Contributed by @tacman (#9), in the shape agreed in #8. Thank you.
How it works
- Turn it on in two places:
multipart.enabled: truefor the application, andacceptsMultipart: trueon the method's#[JsonRPCAPI]attribute. A multipart call to a method without the flag is-32600. - The request carries a
jsonrpcform field with the full JSON-RPC request object (scalar params included), plus one part per file, the part name being the parameter name. Declare the parameter asSymfony\Component\HttpFoundation\File\UploadedFileand hydration does the rest. - File validation is Symfony's own: a declared
UploadedFilecompiles toAssert\Typefollowed byAssert\File, somultipart.max_file_bytes(Symfony size notation, e.g.'10Mi') and every PHP upload error come back as-32602naming the field. - The call logger records a file as
{originalName, size, mimeType}metadata, never its content. The OpenAPI generator publishes amultipart/form-datarequest body for flagged methods.
Security
multipart/form-data is a CORS "simple request", so enabling it reopens - for the flagged methods only - the CSRF vector the mandatory Content-Type: application/json closed in 5.0. If your app authenticates with cookies, read the "before you switch it on" section of the docs first.
Limits
Batch stays JSON-only, files at the top level of params only, POST only.
Full docs: docs/multipart.md. Changelog: CHANGELOG.md.
Backwards compatibility: none required. With multipart.enabled: false (the default), nothing changes.