ios 如何将文件上传到 lambda 函数或 API 网关?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31645205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 06:59:28  来源:igfitidea点击:

How to upload file to lambda function or API Gateway?

iosamazon-web-servicesaws-lambdaaws-api-gateway

提问by Henawey

I'm try to upload file from iOS to AWS API Gateway and passthrough it to Lambda function, How can I implement this scenario?

我正在尝试将文件从 iOS 上传到 AWS API Gateway 并将其传递给 Lambda 函数,我该如何实现这个场景?

I can use multipart/form-datato upload to AWS API Gateway but how make input Model support binary data?

我可以使用multipart/form-data上传到 AWS API Gateway 但如何让输入模型支持二进制数据?

[Edit1] moved from answer by Spektre

[Edit1] 从 Spektre 的回答中移出

Thanks For response, after a little of reading I figure out that's no way to upload file to lambda (and it's not logical because it's event based) and the only valid use case to upload to S3 and make S3 notify lambda.

感谢您的回复,经过一些阅读后,我发现无法将文件上传到 lambda(这不合逻辑,因为它是基于事件的),并且是上传到 S3 并使 S3 通知 lambda 的唯一有效用例。

采纳答案by kixorz

I'd highly recommend using direct S3upload using one of the AWS SDKs. AWS Lambdais suited to process just short events, not content transfers like uploads. You can check its billing and limits to make a more informed decision on if it's really something you're looking for.

我强烈建议使用直接S3使用的一个上传AWS SDKsAWS Lambda适用于仅处理短事件,而不是像上传那样的内容传输。您可以检查其计费和限制,以做出更明智的决定,以确定它是否真的是您正在寻找的东西。

回答by wesman16

API Gateway has added support for an S3 Proxy. This allows you to expose file uploading directly to S3.

API Gateway 增加了对 S3 代理的支持。这允许您将文件上传直接公开到 S3。

http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html

http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-s3.html