Node.js 我可以先处理字段,然后再处理Nodejs busboy中的文件吗

Node.js 我可以先处理字段,然后再处理Nodejs busboy中的文件吗,node.js,busboy,Node.js,Busboy,我正在使用Busboy上传表单数据,其中包含文件和一些文本字段 每件事都很好,我能够得到后参数和文件 我怎样才能做到这一点: 首先,我需要处理字段数据并保存在Db中,处理文件并在Db中的同一记录中更新 服务员首先处理文件,然后处理字段 req.pipe(req.busboy); req.busboy.on('file', function (fieldname, file, filename) { console.log("Uploading: " + filename); co

我正在使用Busboy上传表单数据,其中包含文件和一些文本字段

每件事都很好,我能够得到后参数和文件

我怎样才能做到这一点: 首先,我需要处理字段数据并保存在Db中,处理文件并在Db中的同一记录中更新

服务员首先处理文件,然后处理字段

req.pipe(req.busboy);
req.busboy.on('file', function (fieldname, file, filename) {
    console.log("Uploading: " + filename);
    console.log("fieldname: "+fieldname);
});
req.busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated) {
    var jsondata = JSON.parse(val);
});

任何建议

都很简单:在表单中,只需将字段放在文件之前。例如:


busboy将按照我们附加formData的顺序读取数据

form.append('field',value);
form.appnd('file',file);

不能从服务器端进行控制吗?不,客户端是订购请求数据的客户端。我不知道异步模块如何帮助您解决这个特定问题。