은승우

image

Showing 1 changed file with 6 additions and 39 deletions
......@@ -62,42 +62,6 @@ const client = new line.Client(config);
// register a webhook handler with middleware
// about the middleware, please refer to doc
// Creates a client
var vision = require('google-vision-api-client');
var requtil = vision.requtil;
//Prepare your service account from trust preview certificated project
var jsonfile = '/home/ubuntu/a/LINEBOT/googlevisionapikey';
//Initialize the api
vision.init(jsonfile);
//Build the request payloads
var d = requtil.createRequests().addRequest(
requtil.createRequest('/home/ubuntu/a/LINEBOT/photo/Fancy=TWICE.jpg')
.withFeature('Optical Character Recognition', 3)
.build());
//Do query to the api server
vision.query(d, function(e, r, d){
if(e) console.log('ERROR:', e);
console.log(JSON.stringify(d));
});
app.post('/webhook', line.middleware(config), (req, res) => {
Promise
.all(req.body.events.map(handleEvent))
......@@ -114,9 +78,12 @@ function handleEvent(event) {
// ignore non-message event
return Promise.resolve(null);
}
else if(event.type == 'message' && event.message.type == 'image')
{
else if (event.type == 'message'&& event.message.type == 'image') {
return new Promise((resolve,reject)=>{
var upload = multer({ dest: 'photo/' })
upload.single(event.message.image);
})
}
else if(event.type == 'message' && event.message.type == 'text')
{
......