We theoretically study the transmission of few-photon quantum fields through a strongly nonlinear optical medium. We develop a general approach to investigate nonequilibrium quantum transport of bosonic fields through a finite-size nonlinear medium and apply it to a recently demonstrated experimental system where cold atoms are loaded in a hollow-core optical fiber. We show that when the interaction between photons is effectively repulsive, the system acts as a single-photon switch. In the case of attractive interaction, the system can exhibit either antibunching or bunching, associated with the resonant excitation of bound states of photons by the input field. These effects can be observed by probing statistics of photons transmitted through the nonlinear fiber. Copyright (C) EPLA, 2011