如何使用nodejs从jira服务器下载文件

时间:2015-07-28 06:47:25

标签: node.js jira jira-rest-api sslhandshakeexception

我正在尝试从jira服务器下载文件,但我收到连接拒绝错误(tls握手错误)使用请求模块是否有任何jira模块,我可以用来从jira服务器下载文件

我的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);
});

1 个答案:

答案 0 :(得分: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'));