我正在尝试将文件发送到服务器,但我收到的错误
错误:
poolKey += options.cert.toString('ascii') + options.key.toString('ascii'
^
TypeError: Cannot read property 'toString' of undefined
我的nodejs代码:
var express = require('express');
var app = express();
var request = require('request');
var bodyParser = require("body-parser");
var fs = require('fs');
var https = require('https');
app.use(bodyParser.urlencoded({
extended: false
}));
require('ssl-root-cas/latest').inject();
var options = {
url: 'https://example.com',
agentOptions: {
cert: fs.readFileSync('tstr200011')
},
rejectUnauthorized: false
};
fs.createReadStream('data.xml')
.pipe(request.post(options).auth('user', 'password', false));