我正在将一个csv文件上传到服务器,并且在nodejs的发布请求中,我想最后再添加一行,上传时csv文件已经具有标题了。
var multer = require('multer');
var storage = multer.memoryStorage();
var csvWriter = require('csv-write-stream');
var writer = csvWriter({sendHeaders: false});
var upload = multer({
storage: storage
}).single('file');
exports.uploadContact =(req, res) => {
upload(req, res, function (err) {
writer = csvWriter({sendHeaders: false});
writer.pipe(fs.createWriteStream(req.file.fieldname,{flags: 'a'}));
writer.write({first_name: 'hahahaha'});
writer.end();
});
}
我试图在标题“ first_name”下面的最后一行中添加“ hahaha”,但没有用