編集 - -
上記の質問に対する@Joniのコメントによると、この問題は、プルリクエストを介して修正が送信された後に修正されたようです。
元の回答(OPから)----
Restler(およびメンテナに対応)に関する調査から、Restlerが私が望んでいたことを実行できるようには見えません。注:誰かがストリームの形式でファイル部分を許可するコードをコミットしましたが、それはブランチに受け入れられておらず、私はストリームに関する十分な経験がありません。
基本に戻って問題を解決しました。マルチパートのRFC(http://www.ietf.org/rfc/rfc2388.txt)を読んだところ、本文を作成する際に知っておくべきルールはごくわずかであり、ほとんどの場合、追加の\ r\nと'-がいくつかあります。 -'適切な場所に。
生のPOST本文を単純にフォーマットし、基本ノードのhttpクライアントを介して送信することにしました。
これはうまくいきました:
var http = require('http');
postBody = new Buffer(
'------WebKitFormBoundaryebFz3Q3NHxk7g4qY' + "\r\n" +
'Content-Disposition: form-data; name="upload"; filename="filename.csv"' + "\r\n" +
'Content-Type: text/csv' + "\r\n" +
'\r\n' +
'comma,separated,values' + "\r\n" +
'------WebKitFormBoundaryebFz3Q3NHxk7g4qY' + "\r\n" +
'Content-Disposition: form-data; name="returnUrl"' + "\r\n" +
'\r\n' +
'http://return.url/' + "\r\n" +
'------WebKitFormBoundaryebFz3Q3NHxk7g4qY--'
);
var headers = {
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryebFz3Q3NHxk7g4qY",
"Content-Length": postBody.length
};
//These are the post options
var options = {
hostname: 'myhost.com',
port: 80,
path: '/myPost',
method: 'POST',
headers: headers
};
// so we can see that things look right
console.log("postBody:\n" + postBody);
console.log("postBody.length:\n" + postBody.length);
var responseBody = '';
// set up the request and the callbacks to handle the response data
var request = http.request(options, function(response) {
// when we receive data, store it in a string
response.on('data', function (chunk) {
responseBody += chunk;
});
// at end the response, run a function to do something with the response data
response.on('end',function() {
console.log(responseBody);
});
});
// basic error function
request.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write our post body to the request
request.write(postBody);
// end the request
request.end();
これがmultipart/form-dataを行う人々に役立つことを願っています。