], // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} // Use case: for some types of streams, you'll need to provide "file"-related information manually. // See the form-data README for more information about options: https://github.com/form-data/... custom_file: {
npmjs.org
搜索node-fetch
实现功能的JS调用相应的链接不就可以了
可以使用requset模块做相应的处理即可;
官方文档写的很清楚。
var formData = {
// Pass a simple key-value pair
my_field: 'my_value',
// Pass data via Buffers
my_buffer: new Buffer([1, 2, 3]),
// Pass data via Streams
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
// Pass multiple values /w an Array
attachments: [
],
// Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS}
// Use case: for some types of streams, you'll need to provide "file"-related information manually.
// See the
form-data
README for more information about options: https://github.com/form-data/...custom_file: {
}
};
request.post({url:'http://service.com/upload', formData: formData}, function optionalCallback(err, httpResponse, body) {
if (err) {
}
console.log('Upload successful! Server responded with:', body);
});