mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: file input element - missing path property (#3757)
This commit is contained in:
@@ -68,12 +68,13 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => {
|
||||
});
|
||||
|
||||
const getFile = (e) => {
|
||||
if (e.files?.[0]?.path) {
|
||||
const filePath = window?.ipcRenderer?.getFilePath(e?.files?.[0]);
|
||||
if (filePath) {
|
||||
let relativePath;
|
||||
if (isWindowsOS()) {
|
||||
relativePath = slash(path.win32.relative(root, e.files[0].path));
|
||||
relativePath = slash(path.win32.relative(root, filePath));
|
||||
} else {
|
||||
relativePath = path.posix.relative(root, e.files[0].path);
|
||||
relativePath = path.posix.relative(root, filePath);
|
||||
}
|
||||
formik.setFieldValue(e.name, relativePath);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,10 @@ const General = ({ close }) => {
|
||||
};
|
||||
|
||||
const addCaCertificate = (e) => {
|
||||
formik.setFieldValue('customCaCertificate.filePath', e.target.files[0]?.path);
|
||||
const filePath = window?.ipcRenderer?.getFilePath(e?.target?.files?.[0]);
|
||||
if (filePath) {
|
||||
formik.setFieldValue('customCaCertificate.filePath', filePath);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteCaCertificate = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { ipcRenderer, contextBridge } = require('electron');
|
||||
const { ipcRenderer, contextBridge, webUtils } = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('ipcRenderer', {
|
||||
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
|
||||
@@ -10,5 +10,9 @@ contextBridge.exposeInMainWorld('ipcRenderer', {
|
||||
return () => {
|
||||
ipcRenderer.removeListener(channel, subscription);
|
||||
};
|
||||
},
|
||||
getFilePath (file) {
|
||||
const path = webUtils.getPathForFile(file)
|
||||
return path;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user