은승우

Update app.js

Showing 1 changed file with 4 additions and 6 deletions
...@@ -89,26 +89,24 @@ async function handleEvent(event) { ...@@ -89,26 +89,24 @@ async function handleEvent(event) {
89 client.getMessageContent(event.message.id) 89 client.getMessageContent(event.message.id)
90 .then((stream) => { 90 .then((stream) => {
91 stream.on('data', (chunk) => { 91 stream.on('data', (chunk) => {
92 - fs.writeFileSync('image.png',chunk); 92 + fs.writeFileSync('/photo/1.png',chunk);
93 }); 93 });
94 }); 94 });
95 95
96 96
97 var cheerio = require('cheerio'); 97 var cheerio = require('cheerio');
98 - var imageUrl='oss.chatbot.bu.to/photo/1.png';
99 var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr'; 98 var uriBase = 'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr';
100 var options = { 99 var options = {
101 uri: uriBase, 100 uri: uriBase,
102 qs: { 101 qs: {
103 - visualFeatures: 'Categories', 102 + 'language': 'unk',
104 - details: '', 103 + 'detectOrientation': 'true',
105 - language: 'en'
106 }, 104 },
107 headers: { 105 headers: {
108 'Content-Type': 'application/json', 106 'Content-Type': 'application/json',
109 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc' 107 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc'
110 }, 108 },
111 - body: '{"url": ' + '"' + imageUrl + '"}', 109 + body: fs.readFileSync('/photo/1.png')
112 }; 110 };
113 console.log(body); 111 console.log(body);
114 request.post(options, function (error, response, body) { 112 request.post(options, function (error, response, body) {
......