0
我試圖從FormData xhr請求保存傳入文件,但我甚至不能解析傳入的請求。這是如何我要發送的文件:表達式4 FormData多部分解析POST請求
...
var formData = new FormData();
formData.append(fileType + '-blob', blob);
var request = new XMLHttpRequest();
request.open('POST', url);
request.send(data);
...
這是如何我試圖抓住它:
:var express = require('express');
var router = express.Router();
router.post('/savestream', function(req, res) {
var body = '';
req.on('readable', function() {
body += req.read();
});
req.on('end', function() {
//body = JSON.parse(body);
console.log(body);
res.end(body);
});
});
我也是在我的應用程序使用bodyParser
var bodyParser = require('body-parser');
...
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
...
但是,當我試圖接受它,我得到的原始數據,如:
------WebKitFormBoundaryB0wkHt33s0gbqiB3
Content-Disposition: form-data; name="video-blob"; filename="blob"
Content-Type: video/webm
Eߣ@ B��B��B��B�B�@webmB��B��S�g)I�[email protected](*ױ@[email protected]�@[email protected]�@6T�[email protected]�@0ׁcŁ��"��@und�@V_VP8%��@VP8����@@���C�[email protected]����@���P�*@�>m6�I�#"� (�in�[email protected] ��l����9}�r�d�=���{퓐��'!��NC�l����9}�r�d�=���{퓐��'!��NC�l����9}�r�d�=���{퓐��'!��NC�l����9}�r�d�=���{퓐��'!��NC�l�����
------WebKitFormBoundaryB0wkHt33s0gbqiB3--
我如何解析它?當我發送json數據時效果很好。
明白了'multer'。謝謝! – Footniko