我有兩個nodejs http服務器,一個請求另一個tar文件。它可以通過瀏覽器測試正常工作,但我永遠無法讓第二臺服務器正確地粘貼在一起。我與fwrite的嘗試已經無用,因爲這通過NodeJS下載Tar文件
// Receives File
var complete_file = '';
response.on('data', function(chunk){
complete_file += chunk
}).on('end', function(){
fs.writeFile('/tmp/test.tgz', complete_file, 'binary')
});
// Send File
fs.readFile('/tmp/test_send.tgz', function(err, data){
if (err) throw err;
response.writeHead('200', {
'Content-Type' : 'application/x-compressed',
'Content-Length' : data.length
});
response.write(data);
response.end();
});
對不起,我花了這麼長時間才接受這個作爲一個答案。 – 2010-11-02 06:31:53