From e1153cb5dfb313086fa01b98e1e01825cbd44f8e Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 10 Jun 2024 17:18:06 -0400 Subject: [PATCH] Fixed Message attachments! --- app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 3eb829f..ff0e68c 100644 --- a/app.js +++ b/app.js @@ -107,7 +107,7 @@ async function initialize() { if (messageObj.type === 'icon') { const username = messageObj.username; if (messageObj.avatar) { - const avatarBuffer = Buffer.from(messageObj.avatar, 'base64'); + const avatarBuffer = b4a.from(messageObj.avatar, 'base64'); await drive.put(`/icons/${username}.png`, avatarBuffer); updateIcon(username, avatarBuffer); } else { @@ -115,7 +115,7 @@ async function initialize() { } } else if (messageObj.type === 'file') { if (messageObj.file && messageObj.fileName) { - const fileBuffer = Buffer.from(messageObj.file, 'base64'); + const fileBuffer = b4a.from(messageObj.file, 'base64'); await drive.put(`/files/${messageObj.fileName}`, fileBuffer); const fileUrl = `http://localhost:${servePort}/files/${messageObj.fileName}`; addFileMessage(messageObj.name, messageObj.fileName, updatePortInUrl(fileUrl), messageObj.fileType, updatePortInUrl(messageObj.avatar)); @@ -140,7 +140,7 @@ async function initialize() { const iconMessage = JSON.stringify({ type: 'icon', username: config.userName, - avatar: iconBuffer.toString('base64'), + avatar: b4a.toString(iconBuffer, 'base64'), }); connection.write(iconMessage); } @@ -339,7 +339,7 @@ async function handleFileInput(event) { type: 'file', name: config.userName, fileName: file.name, - file: buffer.toString('base64'), + file: b4a.toString(buffer, 'base64'), fileType: file.type, avatar: updatePortInUrl(config.userAvatar), };