Storage add suceffuly to chat

This commit is contained in:
Eudes Inácio
2022-01-13 17:28:35 +01:00
parent 85c1430857
commit 9f5a0da607
9 changed files with 505 additions and 322 deletions
@@ -60,7 +60,7 @@
<ion-label>{{msg.msg}}</ion-label>
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments let i = index">
<div (click)="downloadFileMsg(msg)">
<div (click)="openPreview(msg)">
<img *ngIf="msg.image_url" src={{msg.image_url}} alt="image">
</div>
<div>
+4 -30
View File
@@ -789,53 +789,27 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('FILE TYPE 44', this.downloadFile)
console.log('TRY ARRAY BUFFER NAME', name);
console.log('TRY ARRAY BUFFER', this.downloadFile);
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
await Filesystem.writeFile({
path: `${IMAGE_DIR}/${name}`,
data: this.downloadFile,
directory: Directory.Data
}).then((foo) => {
console.log('SAVED FILE WEB', foo)
}).catch((error) => {
console.log('SAVED FILE WEB error ', error)
});
const readFile = await Filesystem.readFile({
path: `${IMAGE_DIR}/${name}`,
directory: Directory.Data,
}).then((foo) => {
console.log('GET FILE WEB', foo)
});
}
});
console.log('FILE TYPE 44', this.downloadFile)
}
}
async openPreview(msg) {
if(msg.image_url != "") {
this.downloadFile();
} else {
if(msg.image_url != null) {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.attachments[0].image_url,
image: msg.image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt,
}
});
modal.present();
} else {
this.downloadFileMsg(msg);
}
}