经过长时间的搜索,我开发了一个代码来从字符串中解码wsq文件。因此,现在,当我访问路由时,文件存储在服务器磁盘中。
我的问题是:我该如何向用户下载此文件?
用户可能会下载文件而不将其保存在服务器磁盘中吗?
app.post('/downloadfile', function (req, res) {
file = req.body.image
var Readable = require('stream').Readable
const imgBuffer = Buffer.from(file, 'base64')
var s = new Readable()
s.push(imgBuffer)
s.push(null)
s.pipe(fs.createWriteStream('file.wsq'));
})