electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
https://electronjs.org
MIT License
113.81k stars 15.32k forks source link

File access after building #7477

Closed justijndepover closed 7 years ago

justijndepover commented 7 years ago

Inside my app I have a link to open up an external pdf file. For this to work properly I send a message with IPC from my render process to my main process.

inside my main I have

ipcMain.on('open_file', function(event, file){
    shell.openItem(__dirname + file);
})

inside my render process i have

$('.open_file').on('click', function(event){
    event.preventDefault();

    var url = $(this).data('url');
    ipcRenderer.send('open_file', url)
})

When i use npm start to run my application everything works fine. But when i build my app with electron-builder nothing happens when I try to open the file. No errors show up in my console. Am I doing something wrong with my paths? Or could it be that the electon-builder does not include the pdf's to my package? They live inside my app directory

MarshallOfSound commented 7 years ago

Any issues with electron-builder should be raised on their repository.

That said, electron-builder enables ASAR support by default. When your PDF is in an ASAR you can't call openExternal on it. Read into ASAR support here https://github.com/electron-userland/electron-builder/wiki/Options#BuildMetadata-asar