读取第三方文件-压缩-发送base64编码的数据-不保存任何内容

时间:2019-03-07 11:01:02

标签: node.js node-modules

如何实现这一目标?

require('request').get('http://www.example.com/myfile.pdf', function (err, response, body) {
    //zip the content in body - NO FILE SAVING
    //encode the zipped data and send as response
})

请注意,仅需要zip数据,并且不应在系统中保存zip文件。

1 个答案:

答案 0 :(得分:0)

请求库不适用于此任务。 您应该为此使用Streams。 lib request-stream应该可以为您提供帮助(或者您可以使用其他任何lib,以ReadableStream的形式提供回复)

然后,您应将其pipe压缩到TransformStream以将其zipstream压缩为lib。等等。