mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-21 19:09:20 +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;
|
const file = response.file;
|
||||||
|
|
||||||
// element-web sends a Blob, and the MSC4039 is considering changing the spec to strictly Blob, so only handling that
|
// element-web sends a Blob, and the MSC4039 is considering changing the spec to strictly Blob, so only handling that
|
||||||
if (!(file instanceof Blob)) {
|
if (file instanceof Blob) {
|
||||||
throw new Error("Downloaded file is not a 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