MCPcopy Create free account
hub / github.com/ClydeTime/Surge / getMimeFromBase64

Method getMimeFromBase64

Script/Env.js:454–468  ·  view source on GitHub ↗
(encoded)

Source from the content-addressed store, hash-verified

452 else {
453 // https://stackoverflow.com/questions/57976898/how-to-get-mime-type-from-base-64-string
454 const getMimeFromBase64 = (encoded) => {
455 const signatures = {
456 'JVBERi0': 'application/pdf',
457 'R0lGODdh': 'image/gif',
458 'R0lGODlh': 'image/gif',
459 'iVBORw0KGgo': 'image/png',
460 '/9j/': 'image/jpg'
461 }
462 for (var s in signatures) {
463 if (encoded.indexOf(s) === 0) {
464 return signatures[s]
465 }
466 }
467 return null
468 }
469 media = mediaUrl
470 mime = getMimeFromBase64(mediaUrl)
471 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected