我想通过 koa/node.js 流式传输 ZIP 存档

I want to stream a ZIP archive via koa/node.js

我想流式传输一个 ZIP 文件,但我无法让 streamKoa 中工作。这是我目前所拥有的(已简化)

import Stream from 'stream'
import archiver from 'archiver'

...

 router.get('/zip', async ctx => {

   ctx.set('Content-Type', 'application/zip')

   const content = 'Hey there!'
    
   const archive = archiver('zip', {
      zlib: { level: 9 }, 
   })

   const stream = new Stream.Duplex()
   ctx.body = stream


   archive.pipe(stream)
   archive.append(content, { name: `hello.txt` })
   archive.finalize()
})

但是,我得到这个错误:

Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented

我想念什么?

显然

const stream = new Stream.PassThrough()

有用:)