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

我正在尝试执行上个月成功运行的上述代码,但它突然停止运行,出现错误“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)
4

3 回答 3

1

问题出在图像上。它似乎已损坏(仍然在 MSPaint 中完美打开)。如果我在 MSPaint 中打开图像并将其另存为 JPEG 并尝试将其传递给 AWS Rekognition ,则它可以正常工作。因此,我尝试了一种不同的方法来从 facebook 页面下载图像并且应用程序正常工作。谢谢!!

于 2018-01-11T10:55:10.927 回答
0

config.json,有东西。试试这个

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

让我们改变 Bucket 这个。

const s3bucket = new AWS.S3({params: {Bucket: ''}}); //name Bucket you
于 2018-01-08T10:37:26.740 回答
0

试试这个代码。必需的属性

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

参考: 适用于 JavaScript 的 AWS 开发工具包 - 类:AWS.Rekognition

于 2018-01-09T06:42:56.873 回答