Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I judge when the download is completed after calling saveAs()? #699

Closed
JiangWeian opened this issue Feb 5, 2021 · 2 comments
Closed

Comments

@JiangWeian
Copy link

No description provided.

@TDay1
Copy link

TDay1 commented Mar 7, 2021

I don't believe so, and it wouldn't be possible to implement using the standard web APIs.
It might be possible to do this manually using some weird JS /iFrame hackery, but as far as I know none of the mainstream browsers allow for this functionality outside of webextensions.

@jimmywarting
Copy link
Collaborator

  • It is possible with the new experimental file system access api (currently only available in chrome)
  • It can also somewhat be possible with the help of service worker with a combination of downloading a ReadableStream and Content-Disposition attachment header to simulate how a server would trigger a download. you basically listen on the ReadableStreams pull request when the disk/network IO are are asking for more chunks of data - so you can kind of figure out if it's paused, if it did finish or if it was canceled. StreamSaver is one such tool to help out with this

There is also https://github.com/jimmywarting/native-file-system-adapter wish i have build as a successor after StreamSaver to kind of polyfill the native file system access. it also comes with other supports for different kind of sandboxed file storages and it handles backpressure and pull events better than StreamSaver

Is filesaver.js ever going to support this? most likely not - it tries to be more simpler and only work with blob's and a[download]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants