1
const AWS = require('aws-sdk');
AWS.config.loadFromPath('./config.json');
const rekognition = new AWS.Rekognition({apiVersion: '2016-06-27'});
const constants = require('./constants');
const s3BucketName = constants.s3BucketName;
const s3BucketKeyName = constants.s3FacebookBucketKey;

const params = {
    Image: {
        S3Object: {
            Bucket: "mastekinnoations3learning",
            Name: "1527119837382460.jpeg"
        }
    }
};

rekognition.detectFaces(params, function(err, data) {
if (err)
console.log(err, err.stack); // an error occurred
else     {
    console.log(data);           // successful response
}
});

I am trying to execute the above code which was running successfully last month but it has stopped running suddenly giving error "InvalidParameterException". Any help no what I am missing will be of great help!!

The image that I am using is this

https://s3-us-west-2.amazonaws.com/mastekinnoations3learning/1527119837382460.jpeg

Detailed Error:

{ InvalidParameterException: Request has Invalid Parameters
at Request.extractError (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\protocol\json.js:48:27)
at Request.callListeners (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
at Request.emit (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
at Request.emit (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\state_machine.js:14:12)
at D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request.<anonymous> (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\request.js:38:9)
at Request.<anonymous> (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\request.js:685:12)
at Request.callListeners (D:\Saurabh jain\Personal\nodejsprojects\ImageUpload\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
Sourabh Jain
  • 628
  • 6
  • 20

3 Answers3

1

The issue was with the image. It seems its corrupt(still it opens perfectly in MSPaint). If I open the image in MSPaint and save it as JPEG and they try to pass it to AWS Rekognition , it works correctly. Hence I tried a different approach to download the image from facebook page and the application worked. Thanks!!

Sourabh Jain
  • 628
  • 6
  • 20
0

In the config.json, there is something. Try this out

AWS.config.update({region:'us-east-1',accessKeyId:'',secretAccessKey:''});

Let's change Bucket this.

const s3bucket = new AWS.S3({params: {Bucket: ''}}); //name Bucket you
aofdev
  • 1,772
  • 1
  • 15
  • 29
  • Thanks for reply but its not working. Can you check on this image and see if its working? https://s3-us-west-2.amazonaws.com/mastekinnoations3learning/1527119837382460_1609971089097334-1.jpg – Sourabh Jain Jan 08 '18 at 13:29
0

Try this code. Required Attributes

const params = {
         Image: {
           S3Object: {
              Bucket: "mastekinnoations3learning",
              Name: "1527119837382460.jpeg"
          }
      },
     Attributes:["ALL"]
 };

Ref: AWS SDK for JavaScript - Class: AWS.Rekognition

aofdev
  • 1,772
  • 1
  • 15
  • 29
  • Tried but no success. Can you just pick the above image i.e. https://s3-us-west-2.amazonaws.com/mastekinnoations3learning/1527119837382460_1609971089097334-1.jpg and try it in the AWS Rekognition console. It gives error there also. – Sourabh Jain Jan 10 '18 at 07:02
  • Try changing the picture. – aofdev Jan 10 '18 at 16:46
  • There is some issue with the image. My application downloads the image from facebook and then gives to AWS Rekogniton for processing. if I download the image from facebook via right click it works , however if i download it programmatically , it doesnt works inspite of it being opening in mspaint correctly. – Sourabh Jain Jan 11 '18 at 08:30