electron/docs/api/web-utils.md
trop[bot] 557d5c901a
fix: documentation spelling errors (#43434)
chore: fix typos in 'docs/' folder.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Alexander Cyon <alex.cyon@gmail.com>
2024-08-22 16:04:06 +02:00

967 B

webUtils

A utility layer to interact with Web API objects (Files, Blobs, etc.)

Process: Renderer

Methods

The webUtils module has the following methods:

webUtils.getPathForFile(file)

  • file File - A web 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.

// Before
const oldPath = document.querySelector('input').files[0].path

// After
const { webUtils } = require('electron')
const newPath = webUtils.getPathForFile(document.querySelector('input').files[0])