Rekognition: error when trying to detect faces with s3 object name containing a colon (:)

0

Actually Rekognition works fine but when I use a filename containing a colon (:) for the S3Object, it makes an error. It is very problematic for me because all my files already have colons and I can't change their names.

So if use this It works fine:

{
 "Image":{
   "S3Object":{
   "Bucket":"console-sample-images",
   "Name":"skateboard.jpg"
 }

but if i use a name with a colon like this It gives me an error.

{
 "Image":{
   "S3Object":{
   "Bucket":"console-sample-images",
   "Name":"skate:board.jpg"
 }

Error output: {"name":"Error","content":"{\"__type\":\"InvalidS3ObjectException\",\"Code\":\"InvalidS3ObjectException\",\"Message\":\"Unable to get object metadata from S3. Check object key, region and/or access permissions.\"}","message":"faultCode:Server.Error.Request faultString:'null' faultDetail:'null'","rootCause":{"errorID":2032,"target":{"bytesLoaded":174,"dataFormat":"text","bytesTotal":174,"data":"{\"__type\":\"InvalidS3ObjectException\",\"Code\":\"InvalidS3ObjectException\",\"Message\":\"Unable to get object metadata from S3. Check object key, region and/or access permissions.\"}"},"text":"Error #2032: Stream Error. URL: https://rekognition.eu-west-1.amazonaws.com","currentTarget":{"bytesLoaded":174,"dataFormat":"text","bytesTotal":174,"data":"{\"__type\":\"InvalidS3ObjectException\",\"Code\":\"InvalidS3ObjectException\",\"Message\":\"Unable to get object metadata from S3. Check object key, region and/or access permissions.\"}"},"type":"ioError","bubbles":false,"eventPhase":2,"cancelable":false},"errorID":0,"faultCode":"Server.Error.Request","faultDetail":null,"faultString":""}

Is there a workaround for this problem? (encoding the ':' a certain way?)

Thank you for your help.

asked 2 years ago505 views
2 Answers
0

Can you update your question with the exact error/stack-trace?

Editing answer to reflect latest update -

aws rekognition detect-faces \
--region us-east-1 \
--image '{"S3Object":{"Bucket":"test-images","Name":"drive:resized.jpg"}}'

works as expected

{
    "FaceDetails": [
        {
            "BoundingBox": {
                "Width": 0.20745284855365753,
                "Height": 0.4039246439933777,
                "Left": 0.15659691393375397,
                "Top": 0.13662810623645782
            }...

Can you double check S3 permissions while calling the API? Do the credentials that are being used to call the RekognitionAPI have get/read access to the S3 bucket?

General advice - The object naming conventions are defined by S3 - https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html

The above link suggests that url encoding special characters might help. Can you try replacing ":" in your request with "%3A"?

AWS
Rohit
answered 2 years ago
  • Thank you for your suggestion. I tried it but I still have an error.

  • There maybe something wrong with your permissions/CLI command -

    aws rekognition detect-faces \
    --region us-east-1 \
    --image '{"S3Object":{"Bucket":"test-images","Name":"drive:resized.jpg"}}'
    

    This is giving me the expected output

    {
        "FaceDetails": [
            {
                "BoundingBox": {
                    "Width": 0.20745284855365753,
                    "Height": 0.4039246439933777,
                    "Left": 0.15659691393375397,
                    "Top": 0.13662810623645782
                }...
    

    Can you double check permissions and post the exact command you are running?

0

Thank you for your help. Indeed the problem doesn't come frome Rekognition. I don't know why but the code I used added a space after the colon. I guess it was for the json readability. Best

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions