mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
throw error on invalid response while downloading attachment
This commit is contained in:
parent
7c47150194
commit
68e9376c5e
1 changed files with 7 additions and 1 deletions
|
@ -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…
Reference in a new issue