handle download erros

This commit is contained in:
SrGooglo 2022-12-09 10:29:39 +00:00
parent fa89325b9d
commit 7a41913207
2 changed files with 6 additions and 4 deletions

View File

@ -98,7 +98,6 @@ export default {
label: "Download media",
icon: "Download",
action: () => {
app.message.info("Downloading media...")
download(media.src)
control.close()
}

View File

@ -1,9 +1,8 @@
export default (uri, filename) => {
app.message.info("Downloading media...")
fetch(uri, {
method: "GET",
headers: {
"Content-Type": "application/pdf",
},
})
.then((response) => response.blob())
.then((blob) => {
@ -29,4 +28,8 @@ export default (uri, filename) => {
// Clean up and remove the link
link.parentNode.removeChild(link)
})
.catch((error) => {
console.error(error)
app.message.error("Failed to download media")
})
}