Bugfix with file sending
This commit is contained in:
parent
f18fce63ce
commit
ef79b2aa9b
18
src/App.vue
18
src/App.vue
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user