apisvc: modified code for file handling