In this blog post I will be focusing on a recent requirement of placing a CSV file in AWS S3 bucket using POST request in form-data, the challenges faced during the execution and it’s solution.
We were supposed to place .csv file to AWS S3 bucket which accepts only POST request to be sent in form-data, but before this we had to call another API to get the curl request/form-data parameters, in which we send a request in JSON format with API-Key(in header for authentication) and filename, number of rows and content-type(in the body part for validation of data), in response we get more parameters such as “file ID”, “upload URL” and few other fields including the AWS security tokens etc. These all parameters we would in turn need to use in our final request were in we will be finally posting the file to.
What is Form-Data?
Before we jump on to the solution we must understand what actually is Form-Data?.
The FormData interface provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the fetch() or XMLHttpRequest.send() method. It uses