throw error on invalid response while downloading attachment

pull/1387/head
Audric Ackermann 5 years ago
parent 7c47150194
commit 68e9376c5e
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -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) {

Loading…
Cancel
Save