webUtils
一个与 Web API 对象(文件、Blob 等)交互的实用程序层。
进程:渲染器
方法
webUtils
模块具有以下方法
webUtils.getPathForFile(file)
file
File - 一个 web File 对象。
返回 string
- 此 File
对象指向的文件系统路径。 如果传入的对象不是 File
对象,则会抛出异常。 如果传入的 File 对象是在 JS 中构建的,并且没有磁盘上的文件支持,则返回一个空字符串。
此方法取代了先前使用 path
属性对 File
对象进行的增强。 下面包含一个示例。
// Before
const oldPath = document.querySelector('input').files[0].path
// After
const { webUtils } = require('electron')
const newPath = webUtils.getPathForFile(document.querySelector('input').files[0])