MCPcopy Create free account
hub / github.com/dailydotdev/apps / base64ToFile

Function base64ToFile

packages/shared/src/lib/base64.ts:1–12  ·  view source on GitHub ↗
(
  dataUrl: string,
  fileName: string,
)

Source from the content-addressed store, hash-verified

1export async function base64ToFile(
2 dataUrl: string,
3 fileName: string,
4): Promise<File> {
5 const res: Response = await fetch(dataUrl);
6 const blob: Blob = await res.blob();
7 const type = dataUrl.substring(
8 dataUrl.indexOf(':') + 1,
9 dataUrl.indexOf(';'),
10 );
11 return new File([blob], fileName, { type });
12}

Callers 1

getDraftImageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected