added validation for invalid file in media API