Mobile send word file

This commit is contained in:
Eudes Inácio
2022-04-05 17:39:14 +01:00
parent 8f2ea2a0c2
commit 74a9b787e9
3 changed files with 11 additions and 8 deletions
@@ -87,6 +87,7 @@
<div (click)="docIndex(i); openPreview(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
<span *ngIf="msg.file.type">
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
<fa-icon *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'" icon="file-word" class="word-icon"></fa-icon>
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon">
</fa-icon>
<fa-icon
+8 -8
View File
@@ -780,10 +780,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log('Add file', JSON.stringify(await this.getBase64(file)))
if (file.type == "application/pdf") {
//if (file.type == "application/pdf") {
const encodedData = btoa(JSON.stringify(await this.getBase64(file)));
const blob = this.base64toBlob(encodedData, 'application/pdf')
const blob = this.base64toBlob(encodedData, file.type)
console.log('Add Blob file', blob)
const formData = new FormData();
@@ -803,9 +803,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}],
temporaryData: formData
});
} else {
/* } else {
console.log('File type invalid')
}
} */
@@ -974,8 +974,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
return blob;
}
openFile(pdfString, filename) {
const blob = this.b64toBlob(pdfString, 'application/pdf')
openFile(pdfString, filename, type) {
const blob = this.b64toBlob(pdfString, type)
let pathFile = ''
const fileName = filename
const contentFile = blob
@@ -991,7 +991,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
.writeFile(pathFile, fileName, contentFile, { replace: true })
.then(success => {
this.fileOpener
.open(pathFile + fileName, 'application/pdf')
.open(pathFile + fileName, type)
.then(() => console.log('File is opened'))
.catch(e => console.log('Error opening file', e));
})
@@ -1025,7 +1025,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
modal.present();
} else {
this.openFile(str, msg.attachments[0].name);
this.openFile(str, msg.attachments[0].name, msg.file.type);
}
}