node.js - Saving an image from LINE messaging app to google cloud storage -


i working on project requires retrieve image line message , save google cloud storage. tried same thing facebook messenger , works, doesn't work line. using nodejs express , request middleware this. saving function:

var line_download = function(url, filename, callback){   request.head(url,      {         'auth': {'bearer': appconfig.line_token},         'encoding': null     },     function(err, res, body){     if(res === undefined){         console.log(err);     } else {         // saving image gcs         var localurlstream = request(url);         var file = bucket.file(filename);         var remotewritestream = file.createwritestream();         var stream = localurlstream.pipe(remotewritestream);          stream.on('error', function (err) {             next(err);         });          stream.on('finish', function(){             callback(filename);         });     }   }); }; 

the main difference between fb messenger , line that, fb messenger url created image within message, , have create read url , use createwritestream save google storage, line retrieve binary data of image through webhook.

when @ remotewritestream variable, 2 quite different: 1 facebook incomingmessage object, whereas line duplex object. think might cause of problem, have no idea how solve new development. advice super helpful!!


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -