#Error with importing const {writeFile} = require('fs') in preload.js
50 messages · Page 1 of 1 (latest)
sandbox: false in webPreferences
how do you know this? And how do I find this myself?
Electron 20.0.0 has been released! It includes upgrades to Chromium 104, V8 10.4, and Node.js 16.15.0. Read below for more details!
One key security feature in Chromium is that processes can be executed within a sandbox. The sandbox limits the harm that malicious code can cause by limiting access to most system resources — sandboxed processes can only freely use CPU cycles and memory. In order to perform operations requiring additional privilege, sandboxed processes use dedi...
relatively new thing so everyone have issue with it
I see, thanks again!
running into one last error.
async function handleStop(e) {
const blob = new Blob(recordedChunks, {
type: 'video/webm; codecs=vp9'
});
const buffer = await blob.arrayBuffer();
const filePath = window.electron.openFile();
if (filePath){
window.electron.saveFile(buffer, filePath);
}
}
Uncaught (in promise) Error: filePath is not defined
need full stacktrace
as in how the function is running?
render.js:79 Uncaught (in promise) Error: filePath is not defined
at MediaRecorder.handleStop (render.js:79:19)
handleStop @ render.js:79
openFile: () => ipcRenderer.invoke('dialog:openFile'),
ipcMain.handle('dialog:openFile', handleFileOpen);
async function handleFileOpen() {
const { canceled, filePaths } = await dialog.showOpenDialog({
properties: ["openDirectory"],
});
if (canceled) {
return
} else {
return filePaths[0]
}
}
const filePath = await window.electron.openFile();
Uncaught (in promise) Error: filePath is not defined
at MediaRecorder.handleStop (render.js:79:19)
handleStop @ render.js:79
now getting that
mm
and 79 is window.electron.saveFile(buffer, filePath);
I also tried console.log(filePath)
and it printed the path just fine
show me saveFile function
uh oh
I think I caught it
🤦♂️
I caught the first error
saveFile: () => writeFile(filePath, buffer, () => console.log('video saved successfully!')),
saveFile: (filePath, buffer) => writeFile(filePath, buffer, () => console.log('video saved successfully!')),
now getting render.js:80 Uncaught (in promise) Error: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of ArrayBuffer
at MediaRecorder.handleStop (render.js:80:19)
window.electron.saveFile(buffer, filePath)
looks like need to convert arraybuffer
🤦♂️
I think I still need to convert to buffer
must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of ArrayBuffer
at MediaRecorder.handleStop
holy cow!
it worked!
@sharp egret thank you so much dude!
thank you for guiding me along. I'm brand new to this and it's very confusing. I really appreciate your help!