AWS Rekognition Error - InvalidparameterException

时间:2018-01-05 13:56:10

标签: node.js amazon-web-services aws-sdk amazon-rekognition

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
}
});

我正在尝试执行上个月成功运行的上述代码,但它已经停止运行,突然发出错误" InvalidParameterException"。任何帮助,没有我错过的将是非常有帮助!!

我正在使用的图像是

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

详细错误:

{ 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)

3 个答案:

答案 0 :(得分:0)

config.json中,有一些东西。 试试这个

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

让我们改变Bucket this。

const s3bucket = new AWS.S3({params: {Bucket: ''}}); //name Bucket you

答案 1 :(得分:0)

试试这段代码。必需属性

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

参考: AWS SDK for JavaScript - Class: AWS.Rekognition

答案 2 :(得分:0)

问题在于图像。它看似腐败(仍然在MSPaint完全打开)。如果我在MSPaint中打开图像并将其保存为JPEG并尝试将其传递给AWS Rekognition,则它可以正常工作。因此,我尝试了一种不同的方法从Facebook页面下载图像,应用程序工作。 谢谢!