Repository navigation
Asset upload refuses text/plain and application/json with "No file was sent." (REST and MCP upload_asset) #8178
DescriptionUploading a file with Environment
Steps to reproduce
Actual behavior
The REST call in step 3 answers ( Expected behaviorThe file is stored. The route description already says the type served back comes from the file name's extension rather than from the request. Cause
The File Manager also sends the browser's file type ( Suggested fixRegister the buffer parser for |
Replies: 2 comments 1 reply
|
Your explanation matches the parser selection behavior. I checked it with a small Fastify 5.12.7 A scoped replacement for all three types works: await app.register(async upload => {
upload.addContentTypeParser(
['application/json', 'text/plain', '*'],
{ parseAs: 'buffer', bodyLimit: uploadMaxFileSize },
(_req, body, done) => done(null, body)
);
// Register only the existing asset-upload POST here, keeping its
// permission checks, preParsing hook, schema, and handler.
});The important integration detail is to put the upload route itself in that child scope, leaving the ordinary JSON API routes outside it. Replacing the parsers in the current assets module's entire scope would also affect its JSON-consuming sibling routes. Fastify's parser documentation explains this encapsulation. In the reproduction, I checked:
I would avoid recovering this by serializing an already-parsed This verifies the Fastify mechanism and the proposed scope boundary; I have not run the complete Wiki.js upload/authorization pipeline. A full regression test should exercise the actual registered route, including its existing upload permission and size checks. |
|
Fixed in 3.0.2 |
Fixed in 3.0.2