How to use the compress-commons/lib/archivers/zip/constants.METHOD_STORED function in compress-commons

To help you get started, we’ve selected a few compress-commons 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 ksoichiro / node-archiver-zip-encryptable / lib / zip-crypto-stream.js View on Github external
ZipCryptoStream.prototype._appendBuffer = function(ae, source, callback) {
  ae.gpb.useEncryption(true);
  // Use data descriptor whatever the method is,
  // because when using encryption, we need to calculate
  // the compressed size with encrypted data.
  ae.gpb.useDataDescriptor(true);
  ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR);

  if (source.length === 0) {
    ae.setMethod(constants.METHOD_STORED);
  }

  this._writeLocalFileHeader(ae);

  var method = ae.getMethod();
  if (
    method === constants.METHOD_STORED ||
    method === constants.METHOD_DEFLATED
  ) {
    this._smartStream(ae, callback).end(source);
  } else {
    callback(new Error('compression method ' + method + ' not implemented'));
  }
};