moving file api calls into a service and updating controller