const str=`今天天气不错,挺风和日丽的。`;
const downloadOptions = {
'Content-Disposition': `attachment; filename*=UTF-8''str.txt`,
'Content-Type': 'text/plain',
};
const bufferStream = new Stream.PassThrough();
bufferStream.end(Buffer.from(str, 'utf8'));
bufferStream.pipe(response).writeHead(200, downloadOptions);
这里的response可以是express的response