Skip to content

Instantly share code, notes, and snippets.

@marianmoldovan
Created January 18, 2017 10:37
Show Gist options
  • Save marianmoldovan/a9d2c11185577529f5ae965192221363 to your computer and use it in GitHub Desktop.
Save marianmoldovan/a9d2c11185577529f5ae965192221363 to your computer and use it in GitHub Desktop.
AWS Lambda Rekognition API
'use strict';
const request = require('request').defaults({ encoding: null });
const aws = require('aws-sdk');
const rekognition = new aws.Rekognition({region: 'eu-west-1'});
exports.handler = function(event, context, callback) {
request(event.url, function (error, response, body) {
if (!error && response.statusCode == 200) {
var params = {
Image: {
Bytes: body
},
MaxLabels: 10,
MinConfidence: 0.5
};
rekognition.detectLabels(params, function(err, data) {
if(err || data.Labels.length < 1)
callback(err || 'No items here...');
else {
callback(err, data);
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment