小编Pra*_*kar的帖子

如何在Azure中使用Node JS函数上传文件

我正在尝试创建一个Azure函数来处理文件上传。我尝试了其他选项(尝试直接从请求中读取或使用强大的功能)。

对于这两种情况,执行函数时都会出现以下错误。

Exception while executing function: Functions.UploadFile. mscorlib: TypeError: req.on is not a function  
    at IncomingForm.parse (D:\home\site\wwwroot\node_modules\formidable\lib\incoming_form.js:117:6)  
    at module.exports (D:\home\site\wwwroot\UploadFile\index.js:5:10)  
    at D:\Program Files (x86)\SiteExtensions\Functions\1.0.11702\bin\azurefunctions\functions.js:106:24.  
Run Code Online (Sandbox Code Playgroud)

功能代码如下

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();  
};  
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏。

azure node.js azure-functions serverless

5
推荐指数
2
解决办法
1225
查看次数

标签 统计

azure ×1

azure-functions ×1

node.js ×1

serverless ×1