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 in bucket 'A', the json that gets built in S3 event, key as "key": "New+Text+Document.txt".

空格已替换为"+".我知道这是一个已知的问题,通过在网络上搜索. 但是我不确定如何修复这个问题,并且传入的json本身有一个‘+’,而‘+’实际上可以在文件名中.如‘New+Text Document.txt’.

So I cannot blindly have logic to space '+' by ' ' in my lambda function.

由于此问题,当代码try 在存储桶中查找文件时,它无法找到它.

请建议.

推荐答案

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"
                }
            }
        }
    ]
}

现在JSon值"New+Text+Document.txt"被转换为新的文本文档.没错.

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

Json相关问答推荐

在Go中,当字段可以根据其他字段具有不同的类型时,什么是正确的方法来卸载JSON?

有没有办法让serde_json正确/不正确地处理NaN、inf和-inf(IEEE 754特殊标准)?

使用JQ将对象数组转换为平面数组

(Kotlin)com.google.gson.internal.LinkedTreeMap无法转换为com.example.phonetest2.model.HallData

当并非所有子对象都有 Select 器字段时 Select

使用 serde 和 csv crates 将嵌套的 json 对象序列化为 csv

将来自 Golang 的 JSON API 调用响应输出到 nextjs 前端

golang递归json来构造?

JOLT 在 struct 体中间添加一个 JSON 字段

Serde JSON 反序列化枚举

如果 jq 数组中的字符串是对象或字符串,则获取值

使用 System.Text.Json 序列化记录成员

如何在生产环境中更改 Flutter 应用程序中的数据模型?

boost::json::value 的大括号初始化将其从对象转换为数组

Retrofit 2.0 如何解析嵌套的 JSON 对象?

在 Django 1.9 中,使用 JSONField(本机 postgres jsonb)的约定是什么?

获取一个数字的 PHP 对象属性

处理 HTTP 请求正文中的可选 JSON 字段

如何使用 Jackson 的 objectMapper 反序列化接口字段?

在 iPhone 上解析 JSON 日期