try to solved add file

This commit is contained in:
Eudes Inácio
2023-08-30 18:41:13 +01:00
parent 71ab74974d
commit 79b0c76cfd
2 changed files with 13 additions and 7 deletions
+7 -1
View File
@@ -824,17 +824,23 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
console.log(file)
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
console.log(file.type)
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
)
const fileBase64 = await this._getBase64(file)
console.log(fileBase64)
const formData = new FormData();
formData.append('blobFile', blob);