Answers for "typescript get the mime type from base64 string"

2

typescript get the mime type from base64 string

//if you want to get Mime type use this one

const body = {profilepic:"data:image/png;base64,abcdefghijklmnopqrstuvwxyz0123456789"};
let mimeType = body.profilepic.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0];

//===========================================

//if you want to get only type of it like (png, jpg) etc

const body2 = {profilepic:"data:image/png;base64,abcdefghijklmnopqrstuvwxyz0123456789"};
let mimeType2 = body2.profilepic.match(/[^:/]\w+(?=;|,)/)[0];
Posted by: Guest on October-05-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language