Fix downloaded attachments not being decrypted (#30433)

* Fix downloaded attachments not being decrypted

Fixes https://github.com/element-hq/element-web/issues/30339

* Import order
This commit is contained in:
David Baker
2025-07-30 12:30:18 +00:00
committed by GitHub
parent 452996eacf
commit 1e15a322a5
2 changed files with 46 additions and 7 deletions
+11 -7
View File
@@ -59,15 +59,19 @@ export function useDownloadMedia(url: string, fileName?: string, mxEvent?: Matri
return downloadBlob(blobRef.current);
}
const res = await fetch(url);
if (!res.ok) {
throw parseErrorResponse(res, await res.text());
// We must download via the mediaEventHelper if given as the file may need decryption.
if (mediaEventHelper) {
blobRef.current = await mediaEventHelper.sourceBlob.value;
} else {
const res = await fetch(url);
if (!res.ok) {
throw parseErrorResponse(res, await res.text());
}
blobRef.current = await res.blob();
}
const blob = await res.blob();
blobRef.current = blob;
await downloadBlob(blob);
await downloadBlob(blobRef.current);
} catch (e) {
showError(e);
}