2015-07-28 131 views
0

我試圖從JIRA服務器下載文件,但是我得到使用請求模塊都存在,我可以使用任何JIRA模塊連接被拒絕錯誤(TLS手抖動誤差)下載文件從JIRA服務器下載文件如何從JIRA服務器使用的NodeJS

我的代碼的NodeJS:

var https = require('https'); 
var fs = require('fs'); 
var file = fs.createWriteStream("file.xlsx"); 


var request = https.get("https://gec-jira01.example.com/secure/attachment/206906/A-37_update.xlsx", function(response) { 

    response.pipe(file); 
}); 
+0

使用'的https原來的網址://',而不是'HTTP://'? – yjwong

+0

耶對不起,我現在編輯了錯誤的代碼 – Labeo

回答

0
var credentials = 'user:pass'; 
     var encodedCredentials = new Buffer(credentials).toString('base64'); 

request({ 
          method: "GET", 
          "rejectUnauthorized": false, 
          "url": url, 
          "headers" : 
          { 

           "Content-Type": "application/json", 
           "Authorization": "Basic"+' '+encodedCredentials 
          } 


         },function(err,data,body){ 

          //console.log(data.body); 
          console.log('file downloading'); 

         }).pipe(fs.createWriteStream('file.xlsx')); 
相關問題