Cancel a download programatically #250
Unanswered
hrishikesh-k
asked this question in
Q&A
Replies: 1 comment
-
Nevermind, I switched to Vuex store and it magically works now. I still get the error as mentioned, but at least the download gets cancelled. If anyone has any suggestions, I'm still open to ideas. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
My situation is quite similar to: #149
I'm developing a Vue.js based application. I'm using
fetch
to fetch files from an API, converting them to blob withresponse.blob()
, adding them to a zip using fflate and piping that zip to StreamSaver. I'm doing this with a recursive function and doing this for 1 file at the moment. Here's my code:I simply want to add an option to cancel the download. So, I've create an
AbortController
(referenced asthis.$options.static.downloadStop
). I've attached the same signal to thefetch
requests in mycallApi()
method. As soon as I callthis.$options.static.downloadStop.abort()
, thefetch
request gets cancelled, but the download with StreamSaver doesn't stop. So, I'm trying to runthis.$options.static.zipReadableStream.cancel()
but that still doesn't work and throws this error in the console:Failed to execute 'cancel' on 'ReadableStream': Cannot cancel a locked stream
.Thus, the question is, how do I terminate this download? I'm quite lost here, any help would be great!
Here's my repo if it helps (
/src/App.js
is the relevant file): https://github.com/Hrishikesh-K/netlify-file-browser/tree/vite (Check thevite
branch).Beta Was this translation helpful? Give feedback.
All reactions