I select a file then read the file from the path returned by Neutralino.
Neutralino.os.showOpenDialog('Select Image', {
filters: [
{name: 'Images', extensions: ['jpg', 'png']}
]
}).then((__data) => {
Neutralino.filesystem.readFile(__data[0]).then((__string) => {
console.log('LOADED', __string);
}, (__error) => {console.log('ERR', __error)}).catch(__error => {console.log('Error', __error);});
});
In my case, when I select a file on the desktop for instance, the returned path __data[0]
is
C:/Users/Eric/Desktop/1595887262047.jpg
But then when I try to read the file, it silently fails. How do I load a file that is not a relative path?? I have no issue loading files with a relative path.
readFile
is for "[reading] a text file". What you need isreadBinaryFile
.Creating an image from binary in JavaScript is commonly done and well documented, here are some resources:
One possible implementation using SolidJS: