AWS: how to fix S3 event replacing space with '+' sign in object key names in json

后端 未结 7 1441
名媛妹妹
名媛妹妹 2020-12-31 00:23

I have a lamba function to copy objects from bucket \'A\' to bucket \'B\', and everything was working fine, until and object with name \'New Text Document.txt\' was created

7条回答
  •  猫巷女王i
    2020-12-31 00:53

    What I have done to fix this is

    java.net.URLDecoder.decode(b.getS3().getObject().getKey(), "UTF-8")
    
    
    {
        "Records": [
            {
                "s3": {
                    "object": {
                        "key": "New+Text+Document.txt"
                    }
                }
            }
        ]
    }
    

    So now the JSon value, "New+Text+Document.txt" gets converted to New Text Document.txt, correctly.

    This has fixed my issue, please suggest if this is very correct solution. Will there be any corner case that can break my implementation.

提交回复
热议问题