Fix sending empty picture when updating identity without updated picture

Closes #188

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-10-08 19:32:48 +02:00
parent 406b76ef58
commit f99586c897
3 changed files with 46 additions and 6 deletions

View File

@@ -22,3 +22,17 @@ export function buildFileVariable<T>(file: File | null, name: string, alt?: stri
},
};
}
export function readFileAsync(file: File): Promise<string|ArrayBuffer|null> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
resolve(reader.result);
};
reader.onerror = reject;
reader.readAsBinaryString(file);
});
}