![trop[bot]](/assets/img/avatar_default.png)
* fix: remove File.path from types Co-authored-by: Ben Demboski <demboskb@gmail.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * fixup! fix: remove File.path from types fix 'yarn install --frozen-lockfile' error Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
26 lines
979 B
Markdown
26 lines
979 B
Markdown
# webUtils
|
|
|
|
> A utility layer to interact with Web API objects (Files, Blobs, etc.)
|
|
|
|
Process: [Renderer](../glossary.md#renderer-process)
|
|
|
|
## Methods
|
|
|
|
The `webUtils` module has the following methods:
|
|
|
|
### `webUtils.getPathForFile(file)`
|
|
|
|
* `file` File - A web [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object.
|
|
|
|
Returns `string` - The file system path that this `File` object points to. In the case where the object passed in is not a `File` object an exception is thrown. In the case where the File object passed in was constructed in JS and is not backed by a file on disk an empty string is returned.
|
|
|
|
This method superseded the previous augmentation to the `File` object with the `path` property. An example is included below.
|
|
|
|
```js @ts-nocheck
|
|
// Before
|
|
const oldPath = document.querySelector('input').files[0].path
|
|
|
|
// After
|
|
const { webUtils } = require('electron')
|
|
const newPath = webUtils.getPathForFile(document.querySelector('input').files[0])
|
|
```
|