When I use compressing to compress files,it will lose some files when i download and unzip

Viewed 10
const zipStream = new compressing.zip.Stream();

const promises = paths.map((item: string) => {
  return new Promise(async(resolve, reject) => {
    try {
      const readSteam = await oss.getObjectStream(item);
      const filename = item.split('/')?.pop();
      console.log('path:', `./${filename}`)
      // add file to zip by stream
      await zipStream.addEntry(readSteam as any, { relativePath: `./${filename}`})
      resolve(filename);
    } catch (error) {
      reject(error);
    }
  })
})
try {
  await Promise.all(promises)
  ctx.body = zipStream;
} catch (error) {
  ctx.status = 500;
  ctx.body = {
    error
  }
}

}

when i download the zip file and unzip it, the directory will lose some file, I don't know which step is error

0 Answers
Related