chat group add image

This commit is contained in:
Eudes Inácio
2022-02-09 15:27:21 +01:00
parent f9e06f727e
commit 3bb349bfa1
@@ -562,7 +562,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
@@ -608,7 +608,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
@@ -662,7 +662,40 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
});
}
async addFileToChatMobile(types: typeof FileType[] ) {
const roomId = this.roomId
const file = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Base64,
source: CameraSource.Photos
});
console.log('ADDFILECHAT', file)
//const imageData = await this.fileToBase64Service.convert(file)
//console.log('ADDFILECHAT', imageData)
const response = await fetch('data:image/jpeg;base64,'+ file.base64String!);
const blob = await response.blob();
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
"guid": ''
},
temporaryData: formData,
attachments: [{
"title": file.path ,
"image_url": 'data:image/jpeg;base64,' +file.base64String,
"text": "description",
"title_link_download": false,
}]
})
}
async addFileToChat(types: typeof FileType[] ) {