Bugfix with file sending

This commit is contained in:
Noah 2023-10-08 11:55:56 -07:00
parent f18fce63ce
commit ef79b2aa9b

View File

@ -2657,6 +2657,14 @@ export default {
// The image upload button handler. // The image upload button handler.
uploadFile() { uploadFile() {
// Prepare the message now so the channel name will be correct,
// in case they upload a fat file and switch to a wrong channel
// before the data is ready to send.
let msg = {
action: "file",
channel: this.channel,
};
let input = document.createElement('input'); let input = document.createElement('input');
input.type = 'file'; input.type = 'file';
input.accept = 'image/*'; input.accept = 'image/*';
@ -2681,12 +2689,10 @@ export default {
fileByteArray.push(u8array[i]); fileByteArray.push(u8array[i]);
} }
let msg = JSON.stringify({ // Attach the file to the message.
action: "file", msg.message = file.name;
channel: this.channel, msg.bytes = fileByteArray;
message: file.name, msg = JSON.stringify(msg);
bytes: fileByteArray, //btoa(fileByteArray),
});
// Send it to the chat server. // Send it to the chat server.
this.ws.conn.send(msg); this.ws.conn.send(msg);