MCPcopy
hub / github.com/ionic-team/capacitor / readBlobAsBase64

Function readBlobAsBase64

core/src/core-plugins.ts:290–300  ·  view source on GitHub ↗
(blob: Blob)

Source from the content-addressed store, hash-verified

288 * @param blob The blob value to convert to a base64 string
289 */
290export const readBlobAsBase64 = async (blob: Blob): Promise<string> =>
291 new Promise((resolve, reject) => {
292 const reader = new FileReader();
293 reader.onload = () => {
294 const base64String = reader.result as string;
295 // remove prefix "data:application/pdf;base64,"
296 resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);
297 };
298 reader.onerror = (error: any) => reject(error);
299 reader.readAsDataURL(blob);
300 });
301
302/**
303 * Normalize an HttpHeaders map by lowercasing all of the values

Callers 1

requestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected