MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / base64StringtoFile

Function base64StringtoFile

apps/OpenSign/src/utils/fileUtils.js:31–45  ·  view source on GitHub ↗
(base64String, filename)

Source from the content-addressed store, hash-verified

29};
30
31export function base64StringtoFile(base64String, filename) {
32 let arr = base64String.split(","),
33 // type of uploaded image
34 mime = arr[0].match(/:(.*?);/)[1],
35 // decode base64
36 bstr = atob(arr[1]),
37 n = bstr.length,
38 u8arr = new Uint8Array(n);
39 while (n--) {
40 u8arr[n] = bstr.charCodeAt(n);
41 }
42 const ext = mime.split("/").pop();
43 const name = `${filename}.${ext}`;
44 return new File([u8arr], name, { type: mime });
45}
46
47function formatFixedDate(date = new Date()) {
48 const dd = String(date.getDate()).padStart(2, "0");

Callers 1

saveToMySignFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected