은승우

Update app.js

Showing 1 changed file with 4 additions and 3 deletions
...@@ -85,11 +85,12 @@ async function handleEvent(event) { ...@@ -85,11 +85,12 @@ async function handleEvent(event) {
85 } 85 }
86 else if (event.type == 'message'&& event.message.type == 'image') { 86 else if (event.type == 'message'&& event.message.type == 'image') {
87 return new Promise(async(resolve,reject)=>{ 87 return new Promise(async(resolve,reject)=>{
88 - 88 + var file;
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('./photo/1.png',chunk); 92 + fs.writeFileSync('/photo/1.png',chunk);
93 + file=chunk;
93 }); 94 });
94 }); 95 });
95 96
...@@ -106,7 +107,7 @@ async function handleEvent(event) { ...@@ -106,7 +107,7 @@ async function handleEvent(event) {
106 'Content-Type': 'application/json', 107 'Content-Type': 'application/json',
107 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc' 108 'Ocp-Apim-Subscription-Key': '979dc5d63344438fa4701c62feebb7dc'
108 }, 109 },
109 - body: chunk 110 + body: file
110 }; 111 };
111 console.log(body); 112 console.log(body);
112 request.post(options, function (error, response, body) { 113 request.post(options, function (error, response, body) {
......