我是新來的節點和回調。現在,我正在使用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