0
         request(source_url).pipe(async.series([
             function() {
               fs.createWriteStream(path_for_downloads + path.basename(source_url));
             },
             function() {
               done(null);
             }
           ]);
         );

它等待未闭合的括号...

...              );
... 

这有效:

async.series([
                 function() {
                   fs.createWriteStream(path_for_downloads + path.basename(source_url));
                 },
                 function() {
                   done(null);
                 }
               ]);
4

1 回答 1

2
request(source_url).pipe(async.series([
         function() {
           fs.createWriteStream(path_for_downloads + path.basename(source_url));
         },
         function() {
           done(null);
         }
       ]); //close the array, close async.series call, OOPS don't want a semi there
     ); //close the pipe call

我认为那是你的错误。但是,此代码段还有许多其他问题。我认为您想要更多类似的东西:

var stream = request(source_url).pipe(fs.createWriteStream(path_for_downloads + path.basename(source_url));
stream.on('end', done);
stream.on('error', done);
于 2013-06-21T14:58:45.040 回答