mirror of
https://github.com/vector-im/element-call.git
synced 2026-04-15 07:50:26 +00:00
msc4039 support b64 in addition to blob file download
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user