Amazon Rekognition API - S3 元数据问题

Amazon Rekognition API - S3 MetaData Issue

我正在尝试使用 AWS Image Rekognition API 检测图像中的人脸。但出现以下错误:

错误 1:

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 代码 1:

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

对象 "path/to/image/001.jpg" 存在于 AWS S3 存储桶 "bucket-name" 中。并且区域名称也是正确的。

此对象“001.jpg”的权限是:每个人都被授予 Open/Download/view 权限。 对象的元数据:内容类型:image/jpeg

不确定如何调试。有什么解决这个问题的建议吗?

谢谢,

您似乎要求服务获取版本 ID 为 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

从您的请求参数中删除 'Version': 'string',除非您确实打算从版本化存储桶中获取特定版本的对象,在这种情况下,请提供相关对象的实际版本 ID。

我遇到了同样的问题,避免在存储桶中使用“-”或空格,上传的文件名为我解决了这个问题。

也许删除下划线也有帮助。

旧线程,新解决方案: 我收到了同样的错误信息。 我的错误是由于地区不匹配;我的 S3 存储桶位于 us-east-2,但我的识别客户端默认为 us-west-1。 我换了行

client = get_aws_client('rekognition')

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

成功了。