Refine S3 upload script.