发出POST请求并在节点和混合器中上传音频Blob文件

时间:2019-04-13 02:06:09

标签: javascript node.js multer

我正在尝试记录用户的音频文件,然后使用multer通过POST req处理文件

我一直在听this的回答,但未成功

这是我的前端file的codepen

后端文件

var express = require('express');
var request = require('request');
var multer  = require('multer');
var app = express();

app.use(express.static('public'));
app.set("view engine", "ejs"); 

var upload = multer({ dest: __dirname + '/public/uploads/' });
var type = upload.single('upl'); 

app.post('/api/test', type, function (req, res) {
   console.log(req.body);
   console.log(req.file);
   // do stuff with file
});
app.listen(process.env.PORT || 8080, process.env.ID, function() {

        console.log("server started");
        let port = 8080;


    });

在前端记录blob返回Blob(651) {size: 651, type: "audio/ogg; codecs=opus"}

问题出在后端,返回

[Object: null prototype] { upl: '' }
undefined

0 个答案:

没有答案