简体   繁体   中英

Amazon Rekognition API - S3 MetaData Issue

I am trying to detect faces in an image using AWS Image Rekognition API. But getting the following Error:

Error1:

ClientError: An error occurred (InvalidS3ObjectException) when calling the DetectFaces operation: Unable to get image metadata from S3.  Check object key, region and/or access permissions.

Python Code1:

def detect_faces(object_name="path/to/image/001.jpg"):
    client = get_aws_client('rekognition')

    response = client.detect_faces(
        Image={
            # 'Bytes': source_bytes,
            'S3Object': {
                'Bucket': "bucket-name",
                'Name': object_name,
                'Version': 'string'
            }
        },
        Attributes=[
            'ALL',
        ]
    )

    return response

The Object "path/to/image/001.jpg" exists in the AWS S3 Bucket "bucket-name". And the region Name is also correct.

The Permissions for this object '001.jpg' is: Everyone is granted Open/Download/view Permission. MetaData for the Object: Content-Type: image/jpeg

Not sure how to debug this. Any Suggestion to resolve this please ?

Thanks,

You appear to be asking the service to fetch the object with a version id of string .

Version

If the bucket is versioning enabled, you can specify the object version.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: No

http://docs.aws.amazon.com/rekognition/latest/dg/API_S3Object.html#rekognition-Type-S3Object-Version

Remove 'Version': 'string' from your request parameters, unless you really intend to fetch a specific version of the object from a versioned bucket, in which case, provide the actual version id of the object in question.

I had the same issue and avoid using '-' or whitespaces in bucket and uploaded file names solved it for me.

Maybe removing underscores can also help.

Old thread, new solution: I got the same error message. My mistake was due to a region mismatch; My S3 bucket was residing in us-east-2, but my recognition client defaulted to us-west-1. I changed the line

client = get_aws_client('rekognition')

to

client = get_aws_client('rekognition', region_name='us-east-2')

and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM