FileSystemFileHandle: getFile() method
The getFile()
method of the FileSystemFileHandle
interface returns a Promise
which resolves to a File
object representing the state on disk of the entry represented by the handle.
If the file on disk changes or is removed after this method is called, the returned File
object will likely be no longer readable.
Syntax
Parameters
Return value
A Promise
which resolves to a File
object.
Exceptions
Examples
The following asynchronous function presents a file picker and once a file is chosen, uses the getFile()
method to retrieve the contents.
async function getTheFile() {
[fileHandle] = await window.showOpenFilePicker(pickerOpts);
const fileData = await fileHandle.getFile();
}
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
getFile |
86 |
86 |
111 |
No |
72 |
15.2 |
No |
86 |
111 |
61 |
15.2 |
14.0 |
See also