我需要对使用 Go 通过 AWS Lambda 上传的上传文件的内容进行一些简单的操作,但不确定如何解析接收内容,因为我是 Go 的新手。到目前为止,我发现的解决方案与http包和多部分表单功能有关。
type Request events.APIGatewayProxyRequest
func Handler(ctx context.Context, req Request) (Response, error) {
fmt.Println(req.Body)
....
}
这就是我的请求正文的样子
------WebKitFormBoundaryx0SVDelfa90Fi5Uo
Content-Disposition: form-data; name="file"; filename="upload.txt"
Content-Type: text/plain
this is content
------WebKitFormBoundaryx0SVDelfa90Fi5Uo--
我的请求是 的实例。APIGatewayProxyRequest
我想知道是否有可能获得一个自定义结构,从中我可以访问f.e.等数据。
customStruct.content => "this is content"
customStruct.fileName => upload.txt
customStruct.fileExtension => txt
开满天机
UYOU
相关分类