upload file on chat its done

This commit is contained in:
Eudes Inácio
2023-08-31 13:07:52 +01:00
parent 081fe8692c
commit 36bd1fb6a1
6 changed files with 31 additions and 26 deletions
+17 -9
View File
@@ -829,24 +829,32 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log(file)
/* const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
console.error(error);
})));
const blob = this.fileService.base64toBlob(encodedData, file.type)
const fileBase64 = await this._getBase64(file)
const formData = new FormData();
formData.append('blobFile', blob);
console.log('add file', fileBase64) */
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
console.log('TYPE',file.type)
const encodedData = 'data:application/pdf;base64,'+btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
console.error(error);
})));
console.log(encodedData)
const blob = this.fileService.base64toBlob(encodedData, file.type)
console.log('BLOB BLOB',blob)
/* const fileBase64 = await this._getBase64(file)
console.log('BASE&$',fileBase64) */
/* const formData = new FormData();
console.log('add file', formData)
formData.append('blobFile', blob); */
let ob = {'blobFile': blob}
const formData = new FormData();
formData.append('blobFile', blob);
/* console.log('add file', fileBase64) */
this.ChatSystemService.getDmRoom(roomId).send({
file: {
@@ -859,7 +867,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
// "text": "description",
"title_link_download": false,
}],
temporaryData: ob,
temporaryData: formData,
attachmentsModelData: {
fileBase64: encodedData,
}