我正在尝试通过 AWS Javascript SDK 使用 AWS Rekognition API,并UnknownError: Bad Request
在我尝试启动他们的任何检测服务时收到。我想运行标签检测,但在尝试其他方法时遇到相同的错误,例如名人面部检测。我已确保我的帐户可以访问 Rekognition API 并确保我的凭据正确(或者至少相同的凭据适用于附加到同一帐户的 S3)。
我的代码
var aws = require('aws-sdk');
const region = 's3-us-west-2';
const bucket = process.env.S3_VIDEO_BUCKET;
var requesttoken = randString(10) //generates random string
var key = 'path/to/key.mp4';
// used to check for keys to available files
var service = new aws.S3({
accessKeyId: process.env.ACCESS_KEY,
secretAccessKey: process.env.ACCESS_SECRET,
region: region,
endpoint: 'https://'+region+'.amazonaws.com/',
})
var rekognition = new aws.Rekognition({
accessKeyId: process.env.ACCESS_KEY,
secretAccessKey: process.env.ACCESS_SECRET,
region: region,
endpoint: 'https://'+region+'.amazonaws.com/',
apiVersion: '2016-06-27'
})
// check that key is reachable in S3
this.service.getObject({Bucket:bucket,Key:key}, function(err, data){
if(err){
console.error(err, err.stack)
} else {
console.log(data)
}
})
var params = {
Video: {
S3Object: {
Bucket: bucket,
Name: key
}
},
ClientRequestToken: requesttoken,
NotificationChannel: {
RoleArn: 'arn:aws:sns:us-west-2:000000000:example',
SNSTopicArn: 'example'
}
};
rekognition.startContentModeration(params, (err,data)=>{
if (err) {console.log(err, err.stack); return;};
console.log(data)
})
当我运行此代码时,我得到
{ UnknownError: Bad Request
at Request.extractError
(/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/username/Desktop/project_directory/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
message: 'Bad Request',
code: 'UnknownError',
statusCode: 400,
time: 2018-06-29T21:08:27.184Z,
requestId: '2809C3770B525EF0',
retryable: false,
retryDelay: 57.00430269412582 }
我的问题
是否有人对 Rekognition API/AWS 和 JS SDK 足够熟悉,他们知道在这种情况下 Bad Request 可能表示什么?AWS 文档中是否有某处解释了此错误可能表示的含义?