More atob/btoa fixes

This commit is contained in:
Mashintime 2023-02-05 05:54:35 -05:00
parent c774e5a44f
commit 1bd01d7489
2 changed files with 7 additions and 11 deletions

View file

@ -507,7 +507,8 @@ console.log(filepath.filePaths[0])
try {
//fs.readFile(filepath.filePaths[0], 'utf8', function (err, data) {
fs.readFile(filepath.filePaths[0], 'binary', function (err, data) {
//Has to be binary
fs.readFile(filepath.filePaths[0],'binary', function (err, data) {
console.log(data.length)
@ -541,15 +542,10 @@ ipcMain.on('save-file-to-folder',(event,data)=>{
console.log(data.file)
try {
let buffer = Buffer.from(data.file);
let arraybuffer = Uint8Array.from(buffer);
let arraybuffer = Buffer.from(data.file,"base64").toString('utf-8');
console.log(arraybuffer)
fs.writeFile(filepath.filePath, data.file, 'binary', function (err, data) {
//fs.writeFile(filepath.filePath, arraybuffer, function (err, data) {
//fs.writeFile(filepath.filePath, arraybuffer, 'binary', function(err) {
//fs.writeFile(filepath.filePath, new Uint8Array(Buffer.from(data.file)), function (err, data) {
//fs.writeFile(filepath.filePath, Buffer.from(data.file), function (err, data) {
//Has to be binary
fs.writeFile(filepath.filePath, arraybuffer, 'binary', function (err, data) {
})
} catch (err) {
console.log(err);

View file

@ -866,8 +866,8 @@ update_chat = function(obj) {
//var file = atob(obj._attachments[filename]["data"])
db.getAttachment(obj._id, filename).then(function(data) {
console.log(data)
//Rewrote this part to use buffers to ensure encoding is coorect -- n1qm
var binaryString = Buffer.from(data,"base64").toString('utf-8');
//Rewrote this part to use buffers to ensure encoding is corect -- n1qm
var binaryString = atob_FD(data);
console.log(binaryString);
var data_with_attachment = doc.timestamp + split_char + doc.msg + split_char + filename + split_char + filetype + split_char + binaryString;