mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Mobile send word file
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user