Move sendfile-related code closer to source

The expansion of the filepath using realpath causes issues on frontend
boxes because the directory that is being expanded doesn't actually
exist on them. Instead of always expanding the path, we only do so
when passing through to send_file, that way frontend boxes don't have
to worry about the file existing or not when generating urls for
uploads