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

Add EPUB file type support to Web Share API aka navigator.share() #284

Open
evangow opened this issue Oct 9, 2024 · 3 comments
Open

Add EPUB file type support to Web Share API aka navigator.share() #284

evangow opened this issue Oct 9, 2024 · 3 comments

Comments

@evangow
Copy link

evangow commented Oct 9, 2024

The navigator.share() method doesn't currently support EPUB files, but readers want to be able to share EPUBs downloaded in the browser directly to their preferred reading app.

EPUB support in navigator.share() would be incredibly valuable to readers.

I've also submitted this request to Chromium, Webkit, and Firefox (links below).

https://issues.chromium.org/issues/40280918

https://bugs.webkit.org/show_bug.cgi?id=281152

https://connect.mozilla.org/t5/ideas/add-epub-file-type-support-to-web-share-api-aka-navigator-share/idi-p/73814

@marcoscaceres
Copy link
Member

marcoscaceres commented Oct 22, 2024

@evangow, I'm a bit confused about this request... why doesn't this work?:

const file = /* an ePub file gotten from somewhere */;
navigator.share({ files: [file] })

My understanding is that that should work (i.e., you can share any type of file with the API already).

@evangow
Copy link
Author

evangow commented Oct 28, 2024

According to MDN's docs, it's not included in the "shareable file types" https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share#shareable_file_types

Thanks for the heads up though.

I guess those docs are wrong, because it does work in Safari at least, but Chrome throws a "NotAllowedError: Permission denied" error when trying to share an EPUB.

@jonathanKingston
Copy link

Chrome is currently restrictive based on mime and file types.

I personally think this should be relaxed to a deny list of obviously dubious filetypes.

Additionally the spec and current behaviour is somewhat non ideal in that this step applies to share and not canShare:

If document is not allowed to use "web-share", return a promise rejected with a "NotAllowedError" DOMException.

For example if the following throws on share:

const gpxFileContents = new File([blob], filename, { type: 'application/gpx+xml' });
const shareData = {
  files: [gpxFileContents]
}
if (navigator.canShare(shareData)) {
  await navigator.share(shareData);
}

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