은승우

Update app.js

Showing 1 changed file with 6 additions and 11 deletions
......@@ -81,12 +81,8 @@ async function handleEvent(event) {
return Promise.resolve(null);
}
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);
/*
return new Promise(async(resolve,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')
{
......