我是新来的节点和回调。现在,我正在使用async.waterfall来混淆视频,但由于某种原因,我在我的瀑布中插入第二个函数“pipe”后退出了此过程。我没有正确调用它吗?Async.waterfall不会去下一个功能
// Download the video from S3, get thumbnail, and upload to a different S3 bucket.
async.waterfall([
function download(next) {
// Download the video from S3 into a buffer.
s3.getObject({
Bucket: srcBucket,
Key: srcKey
},
next);
},
function pipe(next) {
// Download the video from S3 into a buffer.
console.log("pipe function started");
var params = {Bucket: srcBucket, Key: srcKey};
s3.getObject(params).createReadStream().pipe(file, next);
},
function upload(response, next) {
console.log("upload function started");
// Stream the transformed image to a different S3 bucket.
s3.putObject({
Bucket: dstBucket,
Key: dstKey,
Body: response.Body,
ContentType: response.ContentType
},
next);
}
], function (err) {
if (err) {
console.error(
'Unable to resize ' + srcBucket + '/' + srcKey +
' and upload to ' + dstBucket + '/' + dstKey +
' due to an error: ' + err
);
} else {
console.log(
'Successfully resized ' + srcBucket + '/' + srcKey +
' and uploaded to ' + dstBucket + '/' + dstKey
);
}
callback(null, "message");
}
);
'.pipe'是否需要回拨?我希望你必须注册'next'作为可读流'end'事件的处理函数 – andyk