은승우

Update app.js

Showing 1 changed file with 4 additions and 9 deletions
......@@ -82,11 +82,7 @@ async function handleEvent(event) {
}
else if (event.type == 'message'&& event.message.type == 'image') {
return new Promise(async(resolve,reject)=>{
client.getMessageContent(event.message.id)
.then((stream) => {
stream.on('data', (chunk) => {
client.replyMessage(event.replyToken,chunk).then(resolve).catch(reject);
/*
fs.writeFileSync('./photo/image.png',event.message.image)
var cheerio = require('cheerio');
var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr';
......@@ -101,11 +97,11 @@ async function handleEvent(event) {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc'
},
body: chunk
body: fs.readFileSync('./photo/image.png')
};
request.post(options, function (error, response, body) {
data=body;
var text='';
while(data.indexOf('text\\')!=-1)
{
......@@ -137,10 +133,9 @@ async function handleEvent(event) {
}
client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
});
});*/
});
});
})
}
else if(event.type == 'message' && event.message.type == 'text')
{
......