How do I get my data back from my IpcMain


Nelz

I am creating a drag and drop react and using electron to send and receive my file data. I received senderId and sender in console.log. How can I get the data to appear? What did I miss?

Dropzone.js file

const [fileNames, setFileNames] = useState([]);

const handleDrop = useCallback(acceptedFiles => {
  setFileNames(_.map(acceptedFiles, ({ name, type, path, size, lastModified, 
   lastModifiedDate }) => {
    return { name, type, path, size, lastModified, lastModifiedDate };
  }))
  let formData = new FormData();
  formData.append('uploadedFiles', fileNames);
}, [fileNames]);


useEffect(() => {
  ipcRenderer.send(FETCH_AUDIO_FILES, fileNames);
}, [fileNames]); 

useEffect(() => {
  const handler = (filesWithData) => {
  _.map(filesWithData, (event, data) => {
    console.log(data);
  })
};
ipcRenderer.on(METADATA_COMPLETED, handler);
  return () => ipcRenderer.removeListener(METADATA_COMPLETED, handler);
});

Index.js file

 ipcMain.on(FETCH_AUDIO_FILES, (event, files) => {
    const promises = _.map(files, (file) => {
    return new Promise((resolve, reject) => {
    NodeID3.read(file.path, (err, tags) => {
       resolve({
         ...files,
         ...tags
      })
    })
  })
});

Promise.all(promises).then(results => { 
  event.sender.send(METADATA_COMPLETED, results);
 [![enter image description here][1]][1]});
});
AKX

You cannot send special objects, such as files, over an IPC channel:

Parameters will be serialized using a structured clone algorithm, just like postMessage, so no prototype chain will be included. Sending a function, promise, symbol, WeakMap or WeakSet will throw an exception.
Note: Sending non-standard JavaScript types (such as DOM objects or special Electron objects) is deprecated and will throw exceptions starting with Electron 9.

-- https://www.electronjs.org/docs/api/web-contents#contentssendchannel-args

You can read the file as a Base64 string, a buffer or whatever in the renderer process and send it to the main process, or if you want to select the file you can use e.g. https://www. electronjs.org/docs/api/dialog#dialogshowopendialogbrowserwindow-options ?

Related


How do I get my stuff back?

clown ok, about 10 minutes ago, i put this .py file on my desktop, changed it to executable, when i double clicked it, it opened, all the files on my desktop disappeared, it Created a folder called "Key Database". Does anyone know how to get my stuff back? Tha

How do I get my WordPress back?

display key I have installed bitnami in c:\BitNami (wamp stack is 5.4.24) on Windows XP on local disk and in "c:\BitNami\wampstack-5.4.24-0\apache2\htdocs\wordpress" With wordpress installed, I do some blogging on wordpress. A few days ago my XP crashed and I

How do I get my stuff back?

clown ok, about 10 minutes ago, i put this .py file on my desktop, changed it to executable, when i double clicked it, it opened, all the files on my desktop disappeared, it Created a folder called "Key Database". Does anyone know how to get my stuff back? Tha

How do I get my WordPress back?

display key I have installed bitnami in c:\BitNami (wamp stack is 5.4.24) on Windows XP on local disk and in "c:\BitNami\wampstack-5.4.24-0\apache2\htdocs\wordpress" With wordpress installed, I do some blogging on wordpress. A few days ago my XP crashed and I

How do I get my data from the website for parsing?

username public class ODKortrijkWebservice extends AsyncTask < ODKortrijkInterface, Void, String > { private ODKortrijkInterface listener;@ Override protected String doInBackground(ODKortrijkInterface...arg0) { listener = arg0[0];

How to get my data back

christian goose I am new to dynamic data and trying to Read data from mysql database using PHP Convert this data to JSON Extract data via javascript (jQuery) Insert it into my page. As far as I can tell, 1) and 2) work, 3) seems to work, and 4) solves the prob

How to get my data back

christian goose I am new to dynamic data and trying to Read data from mysql database using PHP Convert this data to JSON Extract data via javascript (jQuery) Insert it into my page. As far as I can tell, 1) and 2) work, 3) seems to work, and 4) solves the prob

My library pane is missing, how do I get it back

Paul I've searched for the shortcut in the Xcode preferences, but I can't find a way to get it back. My current interface: Gereon Xcode 11 and 12 : Click the "Plus" button at the top left of the "Show/Hide Code Review" button. Alternatively, use View > Show Li

My library pane is missing, how do I get it back

Paul I've searched for the shortcut in the Xcode preferences, but I can't find a way to get it back. My current interface: geron Xcode 11 and 12 : Click the "Plus" button at the top left of the "Show/Hide Code Review" button. Alternatively, use View > Show Lib

How do I get my user account back?

advertise On all my computers I create one partition for root and another for /home. This is useful for disasters that require reformatting the ubuntu root without affecting my /home data. After upgrading to 13.10, I had trouble with my wife's computer, so I r

How do I get my old notes back?

crazy Windows 10 got one of those updates where you can sit at your PC and be greeted with "Hi!", "Let's restart the computer". Of course they messed up my sticky notes. They appear to be "subway" updates, which won't be Windows updates unless the functionalit

How do I get my user account back?

advertise On all my computers I create one partition for root and another for /home. This is useful for disasters that require reformatting the ubuntu root without affecting my /home data. After upgrading to 13.10, I had trouble with my wife's computer, so I r

How do I get the syringe back for my app?

impostor I am trying to run a function and inject a service into it. I think it can be implemented easily using $injector. So I tried the following example (simplified example): angular.injector().invoke( [ "$q", function( $q ) { $q.something(); } ] ); The re

My library pane is missing, how do I get it back

Paul I've searched for the shortcut in the Xcode preferences, but I can't find a way to get it back. My current interface: Gereon Xcode 11 and 12 : Click the "Plus" button at the top left of the "Show/Hide Code Review" button. Alternatively, use View > Show Li

How do I get back to my login screen?

c. tower My program is written in Java using Eclipse, my program first needs to log in to the server with a username and password, then authenticated, and then goes to a new page (frame) with a JMenuBar, JMenu, and JMenuItem. The JMenuItem I'm working on is ca

How do I get my dropdown menu back?

Kaz Wolfe Recently I decided I couldn't use KDE for some reason and did a (mostly) seamless uninstall. However, this resulted in a lot of weird icon glitches in a few places: The drop down arrow (or any arrow in it) is now gone and nowhere to be found. Switchi

How do I get my user account back?

advertise On all my computers I create one partition for root and another for /home. This is useful for disasters that require reformatting the ubuntu root without affecting my /home data. After upgrading to 13.10, I had trouble with my wife's computer, so I r

How do I get my desktop icons back on the main display?

bus 42 So I've read several questions - with and without answers - and although this is similar to others, I can see nothing special about the problem I'm having. This is a three part question and I think they are all related hence why they are being asked as

How do I get back my old terminal tabs?

Laughed My terminal tab looks like this. But now it looks like this: So I want to have the last terminal. questioner You just need to open the settings.jsonfile and look for: "terminal.integrated.tabs.enabled": true and make itfalse Then your vscode terminal

My library pane is missing, how do I get it back

Paul I've searched for the shortcut in the Xcode preferences, but I can't find a way to get it back. My current interface: geron Xcode 11 and 12 : Click the "Plus" button at the top left of the "Show/Hide Code Review" button. Alternatively, use View > Show Lib

How do I get my old notes back?

crazy Windows 10 got one of those updates where you can sit at your PC and be greeted with "Hi!", "Let's restart the computer". Of course they messed up my sticky notes. They appear to be "subway" updates, which won't be Windows updates unless the functionalit

How do I get my user account back?

advertise On all my computers I create one partition for root and another for /home. This is useful for disasters that require reformatting the ubuntu root without affecting my /home data. After upgrading to 13.10, I had trouble with my wife's computer, so I r

How do I get my user account back?

advertise On all my computers I create one partition for root and another for /home. This is useful for disasters that require reformatting the ubuntu root without affecting my /home data. After upgrading to 13.10, I had trouble with my wife's computer, so I r

How do I get my dropdown menu back?

Kaz Wolfe Recently I decided I couldn't use KDE for some reason and did a (mostly) seamless uninstall. However, this resulted in a lot of weird icon glitches in a few places: The drop down arrow (or any arrow in it) is now gone and nowhere to be found. Switchi

How do I get my desktop icons back on the main display?

bus 42 So I've read several questions - with and without answers - and although this is similar to others, I can see nothing special about the problem I'm having. This is a three part question and I think they are all related hence why they are being asked as

How do I get back to my app from the Google Maps App?

Jason From my app I'm calling the Google Maps app using an Intent and everything works fine. my question is: How do I get back to my app from the Google Maps app? If you use the device's "back" button, you need to press 4-5 times! Does anyone have a better sol

How do I get back to my app from the Google Maps App?

Jason From my app I'm calling the Google Maps app using an Intent and everything works fine. my question is: How do I get back to my app from the Google Maps app? If you use the device's "back" button, you need to press 4-5 times! Does anyone have a better sol

How do I get back to my app from the Google Maps App?

Jason From my app I'm calling the Google Maps app using an Intent and everything works fine. my question is: How do I get back to my app from the Google Maps app? If you use the device's "back" button, you need to press 4-5 times! Does anyone have a better sol