fix crash when uploading non-media file

closes #341