update for lp_categories,
This commit is contained in:
@@ -10,3 +10,20 @@ export function fileToBase64(file: Blob): Promise<string> {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function base64ToFile(base64String: string, filename?: string): Promise<File> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const arr = base64String.split(',');
|
||||
const type = arr[0].match(/:(.*?);/)![1];
|
||||
const bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
const u8arr = new Uint8Array(n);
|
||||
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
|
||||
const file = new File([u8arr], filename || 'file', { type });
|
||||
resolve(file);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user