java - AWS SDK Lambda Invoke 失败,因为输入不是 Base-64 编码的
问题描述
当我尝试调用 Lambda 函数(以下是我的代码)时,我在 CloudWatch Logs 中收到错误消息,指出输入不是有效的 Base-64 字符串。
String payload = "xxxxxxxxxxx";
SdkBytes payloadBytes = SdkBytes.fromUtf8String(payload);
String routingUri = getRoutingUri();
InvokeRequest invokeRequest = InvokeRequest.builder()
.functionName(routingUri)
.payload(payloadBytes)
.invocationType("RequestResponse")
.build();
InvokeResponse result = lambdaClient.invoke(invokeRequest);
Error : System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
我尝试了各种方法以 Base-64 对请求进行编码,但似乎没有任何效果
- 我的 AWS 开发工具包版本是 2.15.14
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.15.14</version>
</dependency>
请帮忙。
解决方案
在这里,您需要使用 java.util 包中的 Base64.Encoder 对字符串进行结束编码
推荐阅读
- python - 如何使用python从xml文件中提取文本
- c# - c# RawPrintHelper。我如何发送粗体命令
- android - 尽管在 Unity 编辑器中这样做,但 MRTK 按钮按下在 Android 上未正确触发
- django - 用于视图的 Django 函数耗时太长
- javascript - 如何从 Flutter Dart 代码中调用 JS 函数?
- c# - 如何将日期添加到 Microsoft Access?
- windows - ansible 模块 add_host 错误:跳过:没有匹配的主机
- scala - 如何在 IntelliJ 调试器中使用 sparks 隐式转换(例如 $)评估表达式
- c++ - 重新定义宏不能按预期工作
- javascript - 将表中的json数据转换为pdf文件