I want to allow users to upload files as base64 encoded. The results are like:

data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kA...

or

  data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfAAAAAXNSR0IArs4c6QAAAARnQU...

So I'm wondering what is the idomatic way to extract the file extension from the encoded file strings?