Form files: the visitor is told when the problem is the file — why and what to do; UTF-8 file names

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-13 16:51:05 +01:00
co-authored by Claude Fable 5.2
parent b6f9f34705
commit 97202ee03e
18 changed files with 335 additions and 128 deletions
@@ -132,6 +132,8 @@ export async function handleFormSubmit(req: PayloadRequest): Promise<Response> {
const source = Readable.fromWeb(req.body as never)
const parser = busboy({
// browsers send file names as UTF-8 ("Życiorys.pdf"); the parser's default would read them as Latin-1
defParamCharset: 'utf8',
headers: { 'content-type': contentType },
limits: { fields: 8, fieldSize: VALUES_BYTES, files: options.maxFiles * 4 + 1, fileSize: Math.floor(options.maxSizeMB * MB) + 1 },
})