0
這裏是我的要求是能夠找到的服務,但是,從日誌我得到錯誤說的內容類型應該是多部分/形式 - 數據,我應該如何在以下請求中設置內容類型。如何設置內容類型爲多部分/表單數據的node.js要求
var fs = require('fs');
var request = require('request');
var formData = {
// Pass a simple key-value pair
deviceId: '2612',
// Pass data via Buffers
checksum: '132654798',
fileSize: '60',
fileType: 'configuration',
compressionType: 'Z',
// Pass data via Streams
file: fs.createReadStream('C:/Ruby193/Mybugs.txt'),
};
request.post({url:'https://transfer-upload-v1/file', formData: formData,}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});