diff --git a/ts/receiver/attachments.ts b/ts/receiver/attachments.ts index 26bf845ee..d8ab40e25 100644 --- a/ts/receiver/attachments.ts +++ b/ts/receiver/attachments.ts @@ -26,10 +26,16 @@ export async function downloadAttachment(attachment: any) { } // Fallback to using the default fileserver - if (defaultFileserver || !res) { + if (defaultFileserver || !res || !res.ok) { res = await window.lokiFileServerAPI.downloadAttachment(attachment.url); } + if (!res.response || !res.response.data) { + throw new Error( + `downloadAttachment: invalid response for ${attachment.url}` + ); + } + // The attachment id is actually just the absolute url of the attachment let data = new Uint8Array(res.response.data).buffer; if (!attachment.isRaw) {