Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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];
 
PREVIOUS NEXT
Tagged: #typescript #mime #type #string
ADD COMMENT
Topic
Name
8+9 =