Light interaction with ultracold atoms mediated by a nanofiber