mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +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">
|
<div (click)="docIndex(i); openPreview(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||||
<span *ngIf="msg.file.type">
|
<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/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 *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon">
|
||||||
</fa-icon>
|
</fa-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)))
|
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 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)
|
console.log('Add Blob file', blob)
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@@ -803,9 +803,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}],
|
}],
|
||||||
temporaryData: formData
|
temporaryData: formData
|
||||||
});
|
});
|
||||||
} else {
|
/* } else {
|
||||||
console.log('File type invalid')
|
console.log('File type invalid')
|
||||||
}
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -974,8 +974,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
openFile(pdfString, filename) {
|
openFile(pdfString, filename, type) {
|
||||||
const blob = this.b64toBlob(pdfString, 'application/pdf')
|
const blob = this.b64toBlob(pdfString, type)
|
||||||
let pathFile = ''
|
let pathFile = ''
|
||||||
const fileName = filename
|
const fileName = filename
|
||||||
const contentFile = blob
|
const contentFile = blob
|
||||||
@@ -991,7 +991,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
.writeFile(pathFile, fileName, contentFile, { replace: true })
|
.writeFile(pathFile, fileName, contentFile, { replace: true })
|
||||||
.then(success => {
|
.then(success => {
|
||||||
this.fileOpener
|
this.fileOpener
|
||||||
.open(pathFile + fileName, 'application/pdf')
|
.open(pathFile + fileName, type)
|
||||||
.then(() => console.log('File is opened'))
|
.then(() => console.log('File is opened'))
|
||||||
.catch(e => console.log('Error opening file', e));
|
.catch(e => console.log('Error opening file', e));
|
||||||
})
|
})
|
||||||
@@ -1025,7 +1025,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
modal.present();
|
modal.present();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.openFile(str, msg.attachments[0].name);
|
this.openFile(str, msg.attachments[0].name, msg.file.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ export class MessageService {
|
|||||||
console.log(downloadFile)
|
console.log(downloadFile)
|
||||||
} else if (this.file.type == 'application/audio') {
|
} else if (this.file.type == 'application/audio') {
|
||||||
downloadFile = new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '');
|
downloadFile = new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '');
|
||||||
|
} else if (this.file.type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
|
||||||
|
downloadFile = new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.attachments[0] = {
|
this.attachments[0] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user