I have a requirement in which user will upload a zip file via. form-data. I need to unzip a zip file and upload its content to a specific folder on S3 Bucket and In response, I have to give public file path of those unzipped file.
I am thinking of this step:-
- API Gateway (Post Method) which will trigger lamda-function.
- Lambda function will save tempory file and unzip it in a temporary folder.
- PUT those unzipped file via. AWS-SDK (NodeJS) and return JSON response.
Currently, I am having a problem in step 1 I am not able to parse data which is POSTED to me. Let me know if anyone has a solution to parse form-data which is coming via. HTTP POST.
I am new to the server-less framework so If anyone has a better solution then please share.
You don’t really need API Gateway to do what you want to achieve.
All you need do are the following:
Create a Lambda function and configure to it to handle post processor events on an S3 bucket. In other words, when a zip file is uploaded to your S3 bucket, your Lambda function will be triggered.
Manipulate the zip file the way you want in your Lambda function. Unzip, upload the contents to a different bucket in s3, store metadata information in DynamoDB etc or if need be send metadata to SQS for further processing (it all depends on what you want to achieve)
After processing the zip file, delete it from the original S3 bucket. If you prefer to keep the zip file, move it to another S3 bucket. Again, this should be done from your Lambda function.
You can then use any method of your choice to let your users access the unzipped content. This is the stage where API Gateway can come into play (if using a service oriented architecture). Alternatively, you could allow your users to access their own content directly (if you are using say Cognito and AWS S3 SDK)
Thanks @JonathanEkwempu, I understood the flow.