如何将文件流发送到localhost节点获取



在服务器端,我有这个:

app.post('/testReadStream', function(req, res) {
var readStream = req.body;
readStream.pipe(process.stdout);
})
}).listen(443, () => console.log(`Listening on 443`));

我从其他地方提出以下请求:

let readStream = fs.createReadStream(path);
const fileSizeInBytes = fs.statSync(path).size;
fetch('https://localhost:443/testReadStream', {
method: 'POST',
headers: {
"Content-length": fileSizeInBytes
},
body: readStream
}).catch((err) => {
console.log(err);
})

我得到以下错误。

'request to https://localhost:443/testReadStream failed, reason: write EPROTO 4365467072:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:n',

从此链接https://github.com/openssl/openssl/issues/10938我似乎在文件流方面做了一些错误的事情。我从这里复制了它。如何在请求节点fetch或node中发送文件?

我做错了什么?

看起来像是SSL问题。你能试试简单的字符串体吗

body: "text"

SSL问题来自于我将"https"+localhost而不是"localhost";http://localhost">

在那之后,我只需要将req.body更改为req

相关内容

最新更新