How to use the yauzl.fromRandomAccessReaderRetryPromise function in yauzl

To help you get started, we’ve selected a few yauzl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tencentyun / scf-demo-repo / Node8.9_CosUnzipFile / common / UnzipFile.js View on Github external
async init({
    lazyEntries = true,
    autoClose = false,
    decodeStrings = false
  } = {}) {
    const { cosInstance, Bucket, Region, Key, maxTryTime } = this
  
    const reader = new CosRandomAccessReader({ cosInstance, Bucket, Region, Key, maxTryTime })

    const totalSize = await reader.getTotalSize()

    try {
      this.zipFile = await yauzl.fromRandomAccessReaderRetryPromise(reader, totalSize, {
        lazyEntries,
        autoClose,
        decodeStrings
      })
      appendFunction({
        target: this.zipFile,
        keys: ['openReadStream'],
        maxTryTime: 1
      })
    } catch (error) {
      throw {
        error,
        trace: 'UnzipFile.init.yauzl.fromRandomAccessReaderRetryPromise'
      }
    }
  }