은승우

Update app.js

Showing 1 changed file with 6 additions and 6 deletions
...@@ -88,11 +88,7 @@ async function handleEvent(event) { ...@@ -88,11 +88,7 @@ async function handleEvent(event) {
88 .then( 88 .then(
89 async(stream) => { 89 async(stream) => {
90 await stream.on('data', (chunk) => { 90 await stream.on('data', (chunk) => {
91 - file = chunk; 91 + fs.writeFileSync('./photo/1.png',chunk);
92 - console.log(chunk);
93 - });
94 - }
95 - );
96 console.log(file); 92 console.log(file);
97 var cheerio = require('cheerio'); 93 var cheerio = require('cheerio');
98 var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr'; 94 var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr';
...@@ -106,7 +102,7 @@ async function handleEvent(event) { ...@@ -106,7 +102,7 @@ async function handleEvent(event) {
106 'Content-Type': 'application/json', 102 'Content-Type': 'application/json',
107 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc' 103 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc'
108 }, 104 },
109 - body: file 105 + body: fs.readFileSync('./photo/1.png')
110 }; 106 };
111 console.log(options.body); 107 console.log(options.body);
112 request.post(options, function (error, response, body) { 108 request.post(options, function (error, response, body) {
...@@ -143,6 +139,10 @@ async function handleEvent(event) { ...@@ -143,6 +139,10 @@ async function handleEvent(event) {
143 client.replyMessage(event.replyToken,result).then(resolve).catch(reject); 139 client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
144 }); 140 });
145 }); 141 });
142 + });
143 + }
144 + );
145 +
146 146
147 }); 147 });
148 } 148 }
......