我在 node 中使用POST请求上传文件时遇到问题.js.我必须使用request
个模块来完成(没有外部NPM).服务器需要它是多部分请求,file
字段包含文件的数据.看似简单的事情在Node中很难做到.js,无需使用任何外部模块.
我try 过使用this example,但没有成功:
request.post({
uri: url,
method: 'POST',
multipart: [{
body: '<FILE_DATA>'
}]
}, function (err, resp, body) {
if (err) {
console.log('Error!');
} else {
console.log('URL: ' + body);
}
});