Add 'files' parameter to POST; PUT and PATCH methods

As we discussed, I think this is a better implementation of files support. I also refactored a bit of repeated code. Let me know what you think.
Cheers.