fixing rest API service so it will returns an output stream when a command is run
tidying up some of our file utils