seperate mimetype guessing from filename

Makes the mimetype guessing reusable

cc @MTGap @DeepDiver1975 @karlitschek