typescript get the mime type from base64 string

Solutions on MaxInterview for typescript get the mime type from base64 string by the best coders in the world

showing results for - "typescript get the mime type from base64 string"
Elías
09 May 2016
1//if you want to get Mime type use this one
2
3const body = {profilepic:"data:image/png;base64,abcdefghijklmnopqrstuvwxyz0123456789"};
4let mimeType = body.profilepic.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0];
5
6//===========================================
7
8//if you want to get only type of it like (png, jpg) etc
9
10const body2 = {profilepic:"data:image/png;base64,abcdefghijklmnopqrstuvwxyz0123456789"};
11let mimeType2 = body2.profilepic.match(/[^:/]\w+(?=;|,)/)[0];