Использование AWS SDK для Javascript в Angular5 Я вижу следующую ошибку при запуске DetectLabels или DetectFaces и возвращении к обещанию.Когда я печатаю возврат в функции обнаружения, все выглядит правильно.Ошибка появляется только при попытке вернуть результат в обещание.
"core.js:1449 ERROR Error: Uncaught (in promise):
InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
Я подтвердил, что учетная запись, кажется, работает должным образом, поскольку журнал в обратном вызове печатается успешно, и корзина находится в той же области, что и повторное распознавание.Кто-нибудь видел это раньше?
const rekognition = new Rekognition(
{
accessKeyId: this.accessKeyId,
secretAccessKey: this.secretAccessKey,
region: this.region,
signatureCache: false,
signatureVersion: 'v4'
}
);
const req = rekognition.detectLabels(params, function(err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
return null;
}
// response prints to console successfully
console.log(JSON.stringify(data, null, '\t'));
});
req.promise().then(data => {
console.log(data); //Throws Exception
});
}
**** Обходной путь (рабочий)
aws.service
rekogDetechLabels(): AWS.Request<Rekognition.DetectLabelsResponse, AWS.AWSError> {
const params = {
Image: {
S3Object: {
Bucket: this.bucket,
Name: this.fileName
}
}
};
const rekognition = new Rekognition(
{
accessKeyId: this.accessKeyId,
secretAccessKey: this.secretAccessKey,
region: this.region,
signatureCache: false,
signatureVersion: 'v4'
}
);
return rekognition.detectLabels(params, function(err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
return false;
}
});
}
app.component
// Label Rekognition
const req = this.aws.rekogDetechLabels()
.on('success', response => {
console.log(response.data);
this.labels = (<Rekognition.DetectLabelsResponse>response.data).Labels;
}).on('error', err => {
console.log('Error with Rekognition');
});