Skip to content

Commit

Permalink
[Web Share] Add list of usually shareable file types (mdn#11023)
Browse files Browse the repository at this point in the history
* Add note about Chromium's list of accepted file types

Questions about this keep coming up.

* Add table

* Update files/en-us/web/api/navigator/share/index.md

* Update files/en-us/web/api/navigator/share/index.md

* Update files/en-us/web/api/navigator/share/index.md

Co-authored-by: Florian Scholz <[email protected]>

* Update files/en-us/web/api/navigator/share/index.md

Co-authored-by: Florian Scholz <[email protected]>
  • Loading branch information
tomayac and Elchi3 committed Dec 7, 2021
1 parent b08ae0b commit 726914f
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion files/en-us/web/api/navigator/share/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ navigator.share(data)
- `url`: A {{domxref("USVString")}} representing a URL to be shared.
- `text`: A {{domxref("USVString")}} representing text to be shared.
- `title`: A {{domxref("USVString")}} representing a title to be shared. May be ignored by the target.
- `files`: An array of {{domxref("File")}} objects representing files to be shared.
- `files`: An array of {{domxref("File")}} objects representing files to be shared. See [below](#shareable_file_types) for shareable file types.

### Return value

Expand All @@ -64,6 +64,56 @@ The {{jsxref("Promise")}} may be rejected with one of the following `DOMExceptio
- `DataError`
- : There was a problem starting the share target or transmitting the data.

## Shareable file types

The following is a list of usually shareable file types. However, you should always test with {{domxref("navigator.canShare()")}} if sharing would succeed.

- Application
- `.pdf` - `application/pdf` (from Chromium 93)
- Audio
- `.flac` - `audio/flac`
- `.m4a` - `audio/x-m4a`
- `.mp3` - `audio/mpeg` (also accepts `audio/mp3`)
- `.oga` - `audio/ogg`
- `.ogg` - `audio/ogg`
- `.opus` - `audio/ogg`
- `.wav` - `audio/wav`
- `.weba` - `audio/webm`
- Image
- `.bmp` - `image/bmp`
- `.gif` - `image/gif`
- `.ico` - `image/x-icon`
- `.jfif` - `image/jpeg`
- `.jpeg` - `image/jpeg`
- `.jpg` - `image/jpeg`
- `.pjp` - `image/jpeg`
- `.pjpeg` - `image/jpeg`
- `.png` - `image/png`
- `.svg` - `image/svg+xml`
- `.svgz` - `image/svg+xml`
- `.tif` - `image/tiff`
- `.tiff` - `image/tiff`
- `.webp` - `image/webp`
- `.xbm` - `image/x-xbitmap`
- Text
- `.css` - `text/css`
- `.csv` - `text/csv`
- `.ehtml` - `text/html`
- `.htm` - `text/html`
- `.html` - `text/html`
- `.shtm` - `text/html`
- `.shtml` - `text/html`
- `.text` - `text/plain`
- `.txt` - `text/plain`
- Video
- `.m4v` - `video/mp4`
- `.mp4` - `video/mp4`
- `.mpeg` - `video/mpeg`
- `.mpg` - `video/mpeg`
- `.ogm` - `video/ogg`
- `.ogv` - `video/ogg`
- `.webm` - `video/webm`

## Examples

The example below shows a button click invoking the Web Share API to share MDN's URL.
Expand Down

0 comments on commit 726914f

Please sign in to comment.