Try piping it through a zlib.Gunzip before the tar.extract. Something like:

request( uri, options )
    .pipe(require('zlib').createGunzip())
    .pipe( tar.Extract( { path: __dirname + '/extract' } ) )

On Thursday, April 25, 2013 8:40:40 PM UTC-7, Glenn Scott wrote:
>
> I'm missing something obvious... when I download a tarball from Github and 
> attempt to stream it to node-tar, the Extract method tells me I have an 
> invalid tar file.  Any ideas?
>
> var tar     = require( 'tar' )
>   , request = require( 'request' )
>   , UA      = 'test/1.0'
>   , options = { headers: { "User-Agent": UA } }
>   , uri     = 'https://api.github.com/repos/isaacs/node-tar/tarball/master
> '
>   , fs      = require('fs')
>
>
> // this works
>
>   request( uri, options )
>     .pipe( fs.createWriteStream( 'out.tar' ) )
>     .on( "end", function() {
>       console.log( 'done' )
>     })
>     .on( "error", function( e ) {
>       console.log( e )
>     })
>
>
> /*
>
>   // this doesn't work ('Error: invalid tar file')
>
>   request( uri, options )
>     .pipe( tar.Extract( { path: __dirname + '/extract' } ) )
>     .on( "end", function() {
>       console.log( 'done' )
>     })
>     .on( "error", function( e ) {
>       console.log( e )
>     })
>
> */
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to