IDEA-114241 detect fileType when document is fetched
(cherry picked from commit f4e2842)