On Thu, Apr 25, 2013 at 8:40 PM, Glenn Scott <[email protected]> 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 )
> })
>
Right, because as Ryan mentioned, a tarball isn't a tar file, it's a
.tar.gz file. You need something like:
.pipe(zlib.Unzip())
.pipe( tar.Extract( { path: __dirname + '/extract' } ) )
(with the requisite error handling, of course).
--
Martin Cooper
> */
>
>
> --
> --
> 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.
>
>
>
--
--
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.