The mediaGalleries API lets you prompt the user for permission to access media galleries on the user's computer. The permission dialog contains common media locations for the platform and allows the user to specify additional locations. From those locations, only media files will be present in the file system objects.
The media galleries API has two axes of permission parameters:
These two axes and the permission parameters on each axis are described in the table below:
| Axis | Parameter | Effect |
|---|---|---|
| Locations | none | If you do not specify a location permission parameter, your app will not be able to access any media galleries until the user grants permission to access specific media galleries at runtime using the media gallery permission dialog. |
| "allAutoDetected" | Grants your app access to all auto-detected media galleries on the user's computer. This permission causes an install-time prompt to be displayed indicating that the app will have access to the user's media files. | |
| Access type | "read" | Grants your app the right to read files in media galleries. |
| "copyTo" | Grants your app the right to copy files into media galleries. Only valid media files that Chrome is capable of playing or displaying are permitted; files that Chrome is not able to validate will result in a security error. |
Notes:
Below is an example of a manifest file with mediaGalleries permissions:
{
"name": "My app",
...
"permissions": [
{ "mediaGalleries": ["read", "allAutoDetected"] }
],
...
}
This example manifest file will trigger an install-time permission prompt, and let the app read from all auto-detected media galleries on the user's computer. The user may add or remove galleries using the media gallery permission dialog, after which the app will be able to read all the media files from galleries that the user selected.