mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
profile picture done
This commit is contained in:
@@ -676,7 +676,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
"title_link_download": false,
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: base64,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -686,13 +686,18 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
const roomId = this.roomId
|
||||
|
||||
const image = await this.CameraService.takePicture();
|
||||
await this.fileService.saveImage(image);
|
||||
const lastphoto: any = await this.fileService.loadFiles();
|
||||
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
|
||||
const base64 = await fetch(capturedImage);
|
||||
const file = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
const imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
const blob = this.dataURItoBlob(imageBase64)
|
||||
|
||||
console.log(imageBase64)
|
||||
|
||||
const blob = await base64.blob();
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
@@ -704,13 +709,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": capturedImageTitle,
|
||||
"image_url": capturedImage,
|
||||
"title": "file.jpg",
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: imageBase64,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -795,6 +799,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
const response = await fetch(base64);
|
||||
const blob = await response.blob();
|
||||
|
||||
console.log(base64)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
@@ -811,7 +817,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
"title_link_download": false,
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: base64,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -826,6 +832,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
|
||||
|
||||
|
||||
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
||||
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
|
||||
@@ -833,9 +840,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
})));
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
const fileBase64 = await this._getBase64(file)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
formData.append('blobFile', blob);
|
||||
|
||||
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
@@ -851,7 +860,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: fileBase64,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -862,6 +871,18 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
}
|
||||
|
||||
_getBase64(file) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function () {
|
||||
resolve(reader.result)
|
||||
};
|
||||
reader.onerror = function (error) {
|
||||
console.log('Error: ', error);
|
||||
};
|
||||
})
|
||||
}
|
||||
getFileReader(): FileReader {
|
||||
const fileReader = new FileReader();
|
||||
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
|
||||
|
||||
Reference in New Issue
Block a user