I am trying to accept a file stream using fastify and I only get HTTPError: Response code 415 (Unsupported Media Type) in response.
Here's simple code to reproduce this:
// server.js
const fastify = require('fastify')();
fastify.post('/', (req, res) => {
console.log(req);
res.send('ok');
});
fastify.listen(8080);
// client.js
const fs = require('fs');
const got = require('got');
fs.createReadStream('package.json').pipe(got.stream.post('http://localhost:8080'));
The code above works perfectly fine with e.g. hapi.js.
I see a ton of examples (and tests) of sending a stream back to client, but none for accepting one - is that even possible with fastify?
I've also tried adding content type parser from example but that doesn't help:
fastify.addContentTypeParser('*', function (req, done) {
var data = ''
req.on('data', chunk => { data += chunk })
req.on('end', () => {
done(data)
})
})
I am trying to accept a file stream using fastify and I only get
HTTPError: Response code 415 (Unsupported Media Type)in response.Here's simple code to reproduce this:
The code above works perfectly fine with e.g. hapi.js.
I see a ton of examples (and tests) of sending a stream back to client, but none for accepting one - is that even possible with fastify?
I've also tried adding content type parser from example but that doesn't help: