I am trying to create an Azure function that handles file upload. I have tried different options (trying to read from request directly or using formidable).
For both these cases I am getting following error when the function is executed.
Exception while executing function: Functions.UploadFile. mscorlib: TypeError: req.on is not a function
at IncomingForm.parse (D:homesitewwwroot
ode_modulesformidablelibincoming_form.js:117:6)
at module.exports (D:homesitewwwrootUploadFileindex.js:5:10)
at D:Program Files (x86)SiteExtensionsFunctions1.0.11702inazurefunctionsfunctions.js:106:24.
The function code is as below
var formidable = require("formidable");
module.exports = function (context, request) {
context.log('JavaScript HTTP trigger function processed a request.');
var form = new formidable.IncomingForm();
form.parse(request, function (err, fields, files) {
context.res = { body : "uploaded"};
});
context.done();
};
Any help is appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…