Modularize S3 upload code