Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe from request #19

Open
RWOverdijk opened this issue Apr 10, 2017 · 5 comments
Open

Pipe from request #19

RWOverdijk opened this issue Apr 10, 2017 · 5 comments

Comments

@RWOverdijk
Copy link

Cool library. It works fine with files, but I can't get it to work with requests:

const request = require('request');
const unzip   = require('unzip2');

const run = () => {
  let stream = request.get(SDK_URL).pipe(unzip.Parse()).on('entry', entry => {
    entry.autodrain();
  });

  return new Promise((resolve, reject) => {
    stream.on('finish', resolve);
    stream.on('error', reject);
  });
};

This gives me:

{ Error: invalid distance too far back
at Zlib._handle.onerror (zlib.js:355:17) errno: -3, code: 'Z_DATA_ERROR' }

Any ideas?

@mtharrison
Copy link

I'm getting similar errors @RWOverdijk. I'd like to debug. Are you able to provide a file (or URL) to test this with that shows the error?

@RWOverdijk
Copy link
Author

@mtharrison I was using this to download the google chromecast sdk. I worked around it by simply downloading the file first, and then creating a read stream from disk.

@mtharrison
Copy link

Do you know the URL for that? I tried https://developers.google.com/cast/downloads/GoogleCastSDK-Public-3.4.0-Release-ios.zip and it works with the above code. May I ask what OS you're on?

@RWOverdijk
Copy link
Author

@mtharrison
Copy link

Thanks, I'm also on Mac OSX. I tried to run your code above and it's executing just fine with that URL:

const SDK_URL = 'https://developers.google.com/cast/downloads/GoogleCastSDK-Public-3.1.1-Release-ios.zip';

const request = require('request');
const unzip   = require('unzip2');

const stream = request.get(SDK_URL).pipe(unzip.Parse()).on('entry', entry => {
  
  console.log(entry.path);
  entry.autodrain();
});

stream.on('finish', () => console.log('finished'));
stream.on('error', (err) => console.error(err));

Are you able to confirm that running the above gives you an error? Can I ask what versions of Node/Unzip2/Request that you're using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants