【发布时间】:2015-07-07 20:24:15
【问题描述】:
请注意,我正在尝试从流星/节点服务器上传。我正在尝试与 EchoSign REST API 交互。为此,我必须使用多部分 POST 将 pdf 从我的服务器上传到他们的服务器。我已经想出了如何仅使用节点对服务器进行正常的 POST。
如果可能的话,我希望不使用任何额外的模块,而不是使用 fs 和 http 等标准节点模块。
到目前为止,这是我的代码:
var http = require('http');
options = {
host: 'localhost',
port:8080,
path: '/upload',
method: 'POST',
};
var callback = function(response) {
response.setEncoding('utf-8');
var responseString = '';
response.on('data', function(data) {
responseString += data;
});
response.on('end', function() {
console.log(responseString);
});
}
var request = http.request(options, callback);
request.on('error', function(e) {
console.log('There was an error: '+e);
});
request.end();
谁能指出我正确的方向?
【问题讨论】:
-
好吧,我希望不用额外的模块就能做到这一点,但我会试一试。
标签: javascript node.js meteor