Unable to get object metadata from S3. Check object key, region and/or access permissions in aws Rekognition
Solution 1
I had the same problem. What I did to fix it was to rearrange my bucket and the folders. Make sure that your image is directly in your bucket and not in a folder in your bucket. Also double check that the name of the images are correct and that everything is on point.
Solution 2
Check if the S3 and Image Rekognition is in the same region, I know, it's not nice or documented (I guess), but this guys are talking about it here and here
Solution 3
Ensure bucket
region is same as calling region. If you are using AWS CLI
then make sure to include profile with appropriate region.
Solution 4
It happened to me using the AWS rekognition sdk for android , the problem was that the region of the S3 bucket is not the same in my request , so I had to put the correct region in the request (same as S3 bucket ) :
rekognitionClient.setRegion(Region.getRegion(Regions.US_WEST_1));//replace with your S3 region
Solution 5
It seems to me that you dont have enough permissions with that access_key and secret_key! If the credentials are of an IAM user, make sure the IAM user has permission to perform Rekognition compare_faces read operations and s3 read operations! Also check if your s3 source and target object key are correct. And it is better to create roles with required permissions and assume that role to request temporary security credentials instead of using the permanent access keys.
![Harsh Vardhan Parashar](https://lh3.googleusercontent.com/-1aqddAr3Ggo/AAAAAAAAAAI/AAAAAAAAAms/SFAz17Fcqjg/photo.jpg?sz=256)
Comments
-
Harsh Vardhan Parashar almost 2 years
import boto3 if __name__ == "__main__": bucket='MyBucketName' sourceFile='pic1.jpg' targetFile='pic2.jpg' client=boto3.client('rekognition','us-east-1') response=client.compare_faces(SimilarityThreshold=70, SourceImage={'S3Object':{'Bucket':bucket,'Name':sourceFile}}, TargetImage={'S3Object':{'Bucket':bucket,'Name':targetFile}}) for faceMatch in response['FaceMatches']: position = faceMatch['Face']['BoundingBox'] confidence = str(faceMatch['Face']['Confidence']) print('The face at ' + str(position['Left']) + ' ' + str(position['Top']) + ' matches with ' + confidence + '% confidence')
I am trying to compare two images present in my bucket but no matter which region i select i always get the following error:-
botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the CompareFaces operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
My bucket's region is us-east-1 and I have configured the same in my code. what am I doing wrong?
-
Harsh Vardhan Parashar about 6 yearscan you please elaborate? i am a newbie
-
Harsh Vardhan Parashar about 6 yearsokay i have set the credentials by getting the right access keys from aws but it is still showing the same problem.
-
Venkatesh Kuppusamy about 6 yearshow do you run your python script.? What is output of your below lines..? Please check
print(os.environ['AWS_SECRET_ACCESS_KEY']) print(os.environ['AWS_ACCESS_KEY_ID'])
-
Harsh Vardhan Parashar about 6 yearsi just changed the values of keys through command line using "aws configure"
-
Venkatesh Kuppusamy about 6 yearsThat's good. Then check s3 roles in AWS console. S3 Bucket Access to a Specific IAM Role
-
Harsh Vardhan Parashar about 6 yearsi have provided Administrator and Rekognition access to the user. I have created roles but i am unsure about them. Please guide me
-
Harsh Vardhan Parashar over 5 yearsYes, I found out that the names of the bucket, as well as the files stored in it, are case sensitive i.e "hello" != "Hello". Silly mistake.
-
Guillermo Gutiérrez over 4 yearsOr if you have a folder, put the full path to the object:
path/to/my/object.ext
-
gurinder over 2 yearsyes i can second that. even though S3 is Global but it worked when i set the session to the same region as S3