How to upload file to lambda function or API Gateway?

后端 未结 3 1304
甜味超标
甜味超标 2020-12-15 08:18

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

I can use multipart/form-data

相关标签:
3条回答
  • 2020-12-15 08:43

    I'd highly recommend using direct S3 upload using one of the AWS SDKs. AWS Lambda is 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.

    0 讨论(0)
  • 2020-12-15 08:47

    If want to upload file through lambda, one way is to open your AWS API Gateway console.

    Go to

    "API" -> {YourAPI} -> "Settings"

    There you will find "Binary Media Types" section.

    Add following media type:

    multipart/form-data

    Save your changes.

    Then Go to "Resources" -> "proxy method"(eg. "ANY") -> "Method Request" -> "HTTP Request Headers" and add following headers "Content-Type", "Accept".

    Finally deploy your api.

    For more info visit: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-configure-with-console.html

    0 讨论(0)
  • 2020-12-15 08:52

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

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

    0 讨论(0)
提交回复
热议问题