reorder params/files because Amazon S3 errors if params are after file
add support for patch