How do I put a new file onto a branch from the script console via server api

Similar to the functionality discussed in How do I PUT (update) a file using browse of REST api? I would like to create a file directly on a branch via a hook script that will be running on the server. I was wondering if anything in the server side api allows me to do this? Ideally I was hoping to avoid making an http request and bypassing authentication since the code will be executing directly on the server.