【问题标题】:How to upload files from a meteor/node server?如何从流星/节点服务器上传文件?
【发布时间】: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


【解决方案1】:

嗯,最后我没能成功生成多部分体,所以我改用了restler包。它为您处理所有困难的事情,但是,我认为这应该包含在 Meteor.call() 函数中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2018-05-03
    • 2012-08-01
    • 2015-03-25
    相关资源
    最近更新 更多