This is impossible in general. Indeed, if $X$ has a compact support, then its flux through a large enough sphere is $0$, whereas the integral of $f$ over the corresponding ball will not be $0$ if e.g. $f$ is a nonnegative nonzero function over that ball.