diff --git a/src/Avatar.tsx b/src/Avatar.tsx index d0cb243c..46e2bf21 100644 --- a/src/Avatar.tsx +++ b/src/Avatar.tsx @@ -181,9 +181,16 @@ async function getAvatarFromWidgetAPI( const file = response.file; // element-web sends a Blob, and the MSC4039 is considering changing the spec to strictly Blob, so only handling that - if (!(file instanceof Blob)) { - throw new Error("Downloaded file is not a Blob"); + if (file instanceof Blob) { + return file; + } else if (typeof file === "string") { + // it is a base64 string + const bytes = Uint8Array.from(atob(file), (c) => + c.charCodeAt(0), + ); + return new Blob([bytes]); } + throw new Error("Downloaded file format is not supported: " + typeof file + ""); + - return file; }