base64 encoding before passing file to IPC

This commit is contained in:
DJ2LS 2022-11-11 15:39:24 +01:00
parent 8200af1d99
commit d843e716b7
2 changed files with 5 additions and 4 deletions

View file

@ -549,8 +549,8 @@ ipcMain.on('save-file-to-folder',(event,data)=>{
console.log(data.file)
try {
let buffer = Buffer.from(data.file);
let buffer = Buffer.from(atob(data.file));
let arraybuffer = Uint8Array.from(buffer);
console.log(arraybuffer)
fs.writeFile(filepath.filePath, data.file, 'binary', function (err, data) {

View file

@ -861,8 +861,9 @@ function saveFileToFolder(id) {
console.log(data.length)
//data = new Blob([data.buffer], { type: 'image/png' } /* (1) */)
console.log(data)
// we need to encode data because of error "an object could not be cloned"
let Data = {
file: data,
file: btoa(data),
filename: filename,
filetype: filetype,
}
@ -878,7 +879,7 @@ function saveFileToFolder(id) {
}
// function for setting an ICON to the correspinding state
// function for setting an ICON to the corresponding state
function get_icon_for_state(state) {
if (state == 'transmit') {
var status_icon = '<i class="bi bi-check" style="font-size:1rem;"></i>';