I am writing an AWS lambda in Java. This lambda acts as a handler for APIGatewayProxyRequestEvent
.
API gateway endpoint is sending a file as a multipart/form-data in the body.
public class LambdaHandler extends SpringBootRequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
---
}
while trying to implement the business logic, I am first extracting the body into an array of bytes
byte[] file = Base64.decodeBase64(event.getBody().getBytes());
But when I write these bytes to a string for extracting the data from it, I get the following :
log.info("file content : {}", new String(file));
output:
----------------------------728667852190241466147817
Content-Disposition: form-data; name=""; filename="testuplode.json"
Content-Type: application/json
this is a test file
----------------------------728667852190241466147817--
How to fetch the only content of file from a byte stream of multipart file?