Hey, you're trying to minimise the data transfer code of S3 or ec2 or api gateway.
There are the common way through which data will travel. I will minimise it. Ping me
I am an expert in AWS services, linux servers, also in PHP language, as well as I have experience administering EC2 systems under the same linux trend.