은승우

Update app.js

Showing 1 changed file with 4 additions and 9 deletions
...@@ -82,11 +82,7 @@ async function handleEvent(event) { ...@@ -82,11 +82,7 @@ async function handleEvent(event) {
82 } 82 }
83 else if (event.type == 'message'&& event.message.type == 'image') { 83 else if (event.type == 'message'&& event.message.type == 'image') {
84 return new Promise(async(resolve,reject)=>{ 84 return new Promise(async(resolve,reject)=>{
85 - client.getMessageContent(event.message.id) 85 + fs.writeFileSync('./photo/image.png',event.message.image)
86 - .then((stream) => {
87 - stream.on('data', (chunk) => {
88 - client.replyMessage(event.replyToken,chunk).then(resolve).catch(reject);
89 - /*
90 var cheerio = require('cheerio'); 86 var cheerio = require('cheerio');
91 87
92 var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr'; 88 var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr';
...@@ -101,11 +97,11 @@ async function handleEvent(event) { ...@@ -101,11 +97,11 @@ async function handleEvent(event) {
101 'Content-Type': 'application/octet-stream', 97 'Content-Type': 'application/octet-stream',
102 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc' 98 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc'
103 }, 99 },
104 - body: chunk 100 + body: fs.readFileSync('./photo/image.png')
105 }; 101 };
106 102
107 request.post(options, function (error, response, body) { 103 request.post(options, function (error, response, body) {
108 - 104 + data=body;
109 var text=''; 105 var text='';
110 while(data.indexOf('text\\')!=-1) 106 while(data.indexOf('text\\')!=-1)
111 { 107 {
...@@ -137,10 +133,9 @@ async function handleEvent(event) { ...@@ -137,10 +133,9 @@ async function handleEvent(event) {
137 } 133 }
138 client.replyMessage(event.replyToken,result).then(resolve).catch(reject); 134 client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
139 }); 135 });
140 - });*/
141 }); 136 });
137 +
142 }); 138 });
143 - })
144 } 139 }
145 else if(event.type == 'message' && event.message.type == 'text') 140 else if(event.type == 'message' && event.message.type == 'text')
146 { 141 {
......