How and what’s to be configured in API gateway to accept file as an input in AJAX call. Also How to read the contents of the file in Python Lambda? There ain't much help with examples available in the official aws docs
1 Answer
We need to zip the dependencies along with python file and upload it.
For example if you wish to read a file called input.conf in python file reader.py,
you need to create a zip file which includes the above files within it.
/uploader.zip
|- input.conf
| - reader.py
The name of the python file should be the first part of lambda handler, like:
reader.lambda_handler (in case of python)
6 Comments
Jophine
refer: docs.aws.amazon.com/lambda/latest/dg/… for more details
Pavan
I want to upload the file from the browser and user's gonna provide this file.
Jophine
In that case, you need to read the file as bytes (for binary file) or string and add it to request body which will be passed to api gateway.
Jophine
File cannot be passed directly to api gateway (REST accepts payload only as string in json or xml). You should be reading the file from client side and sent it to server as string in the request payload
Pavan
That's my exact question on how to do that?
|