AWS Rekognition Error - InvalidparameterException

不羁的心 提交于 2019-12-25 00:35:21

问题


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)

回答1:


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



回答2:


Try this code. Required Attributes

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

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




回答3:


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!!



来源:https://stackoverflow.com/questions/48115069/aws-rekognition-error-invalidparameterexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!