We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.0.0
16.17.1
Windows
11
reply stream and buffer get 0 size from route.
I use fastify-cli to build a brand new project. and add route
fastify.get("/file", async function (request, reply) { const filePath = path.join(__dirname, "./aaa.txt"); console.log(`filePath`, filePath); const fileStream = fs.createReadStream(filePath, "utf8"); reply.header("Content-Type", "application/octet-stream"); reply.send(fileStream); }); fastify.get("/file1", async function (request, reply) { const filePath = path.join(__dirname, "./aaa.txt"); console.log(`filePath`, filePath); fs.readFile(filePath, (err, fileBuffer) => { reply.send(err || fileBuffer); }); });
to get it but reply 0 size file
reply the right file stream
The text was updated successfully, but these errors were encountered:
When using async-await, please return the reply object to signal fastify wait for your further response.
async-await
reply
fastify
fastify.get("/file", async function (request, reply) { const filePath = path.join(__dirname, "./aaa.txt"); console.log(`filePath`, filePath); const fileStream = fs.createReadStream(filePath, "utf8"); reply.header("Content-Type", "application/octet-stream"); return reply.send(fileStream); }); fastify.get("/file1", async function (request, reply) { const filePath = path.join(__dirname, "./aaa.txt"); console.log(`filePath`, filePath); fs.readFile(filePath, (err, fileBuffer) => { reply.send(err || fileBuffer); }); return reply });
Sorry, something went wrong.
No branches or pull requests
Prerequisites
Fastify version
4.0.0
Plugin version
4.0.0
Node.js version
16.17.1
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Description
reply stream and buffer get 0 size from route.
Steps to Reproduce
I use fastify-cli to build a brand new project.
and add route
to get it but reply 0 size file
Expected Behavior
reply the right file stream
The text was updated successfully, but these errors were encountered: