【问题标题】:How to download a file from a jira server using nodejs如何使用 nodejs 从 jira 服务器下载文件
【发布时间】:2015-10-18 14:06:35
【问题描述】:

我正在尝试从 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);
});

【问题讨论】:

  • 您的原始网址是否使用了https:// 而不是http://
  • 是的,对不起,我现在编辑了错误的代码

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


【解决方案1】:
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'));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-14
    • 2017-07-06
    • 1970-01-01
    • 2015-06-14
    • 2017-02-25
    • 2019-03-30
    相关资源
    最近更新 更多