formidable: fileWriteStreamHandle doesn't call the passed function in express
Avantages
const { PassThrough } = require("stream");
const aws = require("aws-sdk");
const s3 = new aws.S3({
apiVersion: "2006-03-01",
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});
function uploadFile(req, res, next) {
const uploadStream = (filename) => {
const pass = PassThrough();
/* This method is not being called*/
console.log('uploadStream() called);
s3.upload(
{
Bucket: process.env.AWS_BUCKET,
Key: filename,
Body: pass,
},
(err, data) => {
console.log(err, data);
if (err) {
console.log(err);
}
console.log(data);
}
);
return pass;
};
var form = formidable({
maxFileSize: 5 * 1024 * 1024,
minFileSize: 1,
allowEmptyFiles:false,
fileWriteStreamHandler: uploadStream // This method is not being called
});
}
I have followed the example in link https://github.com/node-formidable/formidable/blob/master/examples/store-files-on-s3.js
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (11 by maintainers)
How ?
Sorry for late reply, I have fixed the issue
@sinoon there is a published canary/v2 (npm i formidable@canary) from May 2020 with all the updates. Pushed to master since then isn’t published. I’m getting my machine setup this week.
Hey guys, I’m having the same issue. The function is simply not being called. I installed the
canaryversion of the package.Additionally, the example is invalid as it is missing a
newkeyword before thePassThrough().What version of formidable are you using ?
console.log is missing a single quote ’