sam generate-event - 如何将isBase64设置为false?

0

【以下的问题经过翻译处理】 我一直在学习AWS,并试图在本地测试lambda。目前,我正在尝试通过生成一个事件来测试lambda,就像从API Gateway调用一样。

在构建lambda应用程序后,我使用以下命令。

sam local generate-event apigateway aws-proxy --path retrievestatus --**body {"email":"abc@gmail.com"} **| sam local invoke -e - App

事件生成了并调用了lambda。然而,我在这里有一个小问题。生成的事件拥有以下内容 -

{ "body": "e2VtYWlsOmJ1bHVzdXNhc2hhbmtAZ21haWwuY29tfQ==", "resource": "/{proxy+}", "path": "/retrievestatus", "httpMethod": "POST", "isBase64Encoded": true,

实际上,我的lambda并不需要一个base64编码的字符串。因此,我需要当我在本地使用SAM时,将isBase64Encoded设置为false。

我尝试查看运行“sam local generate-event apigateway aws-proxy -h”支持的选项,但找不到任何可将其关闭的选项。

1 réponse
0

【以下的回答经过翻译处理】 根据github上的代码,事件始终使用base64编码生成。我的建议是手动创建事件并进行修改,然后在使用sam local invoke命令的-e参数调用函数时使用保存的事件。

profile picture
EXPERT
répondu il y a 5 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions