은승우

Update app.js

Showing 1 changed file with 9 additions and 1 deletions
......@@ -82,12 +82,20 @@ function handleEvent(event) {
}
else if (event.type == 'message'&& event.message.type == 'image') {
return new Promise((resolve,reject)=>{
client.getMessageContent(event.message.id).then((stream) => {
stream.on('data', (chunk) => {
request.post( function(error, response, body){
// Translate API Sucess
if(!error && response.statusCode == 200){
client.replyMessage(event.replyToken,event.message.originalContentUrl).then(resolve).catch(reject);
client.replyMessage(event.replyToken,chunk).then(resolve).catch(reject);
}
});
stream.on('error', (err) => {
// error handling
});
});
});
/*console.log("!");
var cheerio = require('cheerio');
......