files/en-us/web/api/filesystemfilehandle/getfile/index.md
{{securecontext_header}}{{APIRef("File System API")}}{{AvailableInWorkers}}
The getFile() method of the
{{domxref("FileSystemFileHandle")}} interface returns a {{jsxref('Promise')}} which resolves to a
{{domxref('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 {{domxref('File')}} object will likely be no longer readable.
getFile()
None.
A {{jsxref('Promise')}} which resolves to a {{domxref('File')}} object.
NotAllowedError {{domxref("DOMException")}}
granted in read mode.NotFoundError {{domxref("DOMException")}}
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() {
// open file picker
const [fileHandle] = await window.showOpenFilePicker(pickerOpts);
// get file contents
const fileData = await fileHandle.getFile();
}
{{Specifications}}
{{Compat}}