diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html
index 452809c49..0572a94fb 100644
--- a/src/app/pages/chat/messages/messages.page.html
+++ b/src/app/pages/chat/messages/messages.page.html
@@ -194,16 +194,19 @@
-
-
+
-
+
@@ -213,7 +216,11 @@
-
+
+
+
+
+
diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts
index 05cd38bb7..b1048a041 100644
--- a/src/app/pages/chat/messages/messages.page.ts
+++ b/src/app/pages/chat/messages/messages.page.ts
@@ -366,6 +366,86 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
}
+ async sendAudio(fileName) {
+
+ const roomId = this.roomId
+
+ /* const file: any = await this.fileService.getFileFromDevice(audio);
+ console.log('Add file', file)
+
+ const blob = new Blob([file],{type: file.type})
+ console.log('Add file', blob)
+
+ const formData = new FormData();
+ formData.append("blobFile", blob);
+
+ let pdfBase64;
+ this.blobToBase64(blob).then(res => {
+ console.log('Base64 pdf', res);
+ this.wsChatMethodsService.getDmRoom(roomId).send({
+ file: {
+ "type": file.type,
+ "guid": '',
+ },
+ attachments: [{
+ "title": file.name ,
+ "title_link": res,
+ "title_link_download": true,
+ "type": "file"
+ }],
+ temporaryData: formData
+ })
+ }); */
+
+ const audioFile = await Filesystem.readFile({
+ path: fileName,
+ directory: Directory.Data
+ })
+ console.log(audioFile);
+ const base64sound = audioFile.data;
+
+ const audioRef = new Audio(`data:audio/aac;base64,${base64sound}`)
+
+ console.log(audioRef);
+
+ //Converting base64 to blob
+ const base64 = await fetch(base64sound);
+ const base64Response = await fetch(`data:audio/aac;base64,${base64sound}`);
+ const blob = await base64Response.blob();
+
+ console.log(blob);
+
+ const formData = new FormData();
+ formData.append("blobFile", blob);
+
+ this.wsChatMethodsService.getDmRoom(roomId).send({
+ file: {
+ "type": "audio/aac",
+ "guid": '',
+ },
+ attachments: [{
+ "title": fileName ,
+ "title_link": audioRef,
+ "title_link_download": true,
+ "type": "file"
+ }],
+ temporaryData: formData
+ })
+
+ alert('OK')
+
+ }
+
+ blobToBase64 = blob => {
+ const reader = new FileReader();
+ reader.readAsDataURL(blob);
+ return new Promise(resolve => {
+ reader.onloadend = () => {
+ resolve(reader.result);
+ };
+ });
+ };
+
viewDocument(msg: any, url?: string) {
console.log(msg)
if (msg.attachments.type == "application/webtrix") {
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts
index 2c768a2c7..9a3d8ef8a 100644
--- a/src/app/shared/chat/messages/messages.page.ts
+++ b/src/app/shared/chat/messages/messages.page.ts
@@ -751,7 +751,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} else {
this.downloadFile = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
}
-
+
msg.file = {
guid: msg.file.guid,
@@ -799,7 +799,7 @@ console.log(msg);
});
modal.present();
}
-
+
}
}