0

クラウド機能を使用してイメージメディアを使用してFirebaseストレージにアップロードされるイメージの高さと幅を取得したい。Firebase用クラウド関数:ImageMagick構文を生成する

私は、次のコードを書いた:ImageMagickのを書き、実行の出力を取得する方法を提案してください

Cannot read property 'on' of undefined 
at mkdirp.then.then (/user_code/index.js 

var child = spawn('identify', ["-ping","-format","`%w %h`",tempLocalFile]); 
child.stdout.on('data', function(data) { 
    console.log('stdout: ' + data); 
    //Here is where the output goes 
}); 
child.stderr.on('data', function(data) { 
    console.log('stderr: ' + data); 
    //Here is where the error output goes 
}); 

しかしfirebaseログがエラーを示しています。

+0

あなたのエラーは、「mkdirp」に問題があることを示しているが、私はあなたが示されたコードでそのどこにも表示されません。表示されていないコードのどこに問題がないのでしょうか? –

答えて

0

問題Cannot read property 'on' of undefinedは、リスナーstdoutstderrの追加方法に由来します。プロセスを取得して、というリスナーを追加する必要があります。spawnが返す約束には直接アクセスできません。コードスニペット:

var spawnPromise = spawn('identify', ["-ping","-format","`%w %h`",tempLocalFile]); 
var childProcess = spawnPromise.childProcess; 
childProcess.stdout.on('data', function(data) { 
    console.log('stdout: ' + data); 
    //Here is where the output goes 
}); 
childProcess.stderr.on('data', function(data) { 
    console.log('stderr: ' + data); 
    //Here is where the error output goes 
}); 
関連する問題