fix bug in s3 upload logic