preview doc on chat solved

This commit is contained in:
Equilibrium ITO
2024-03-18 11:13:34 +01:00
parent a52ff2aef8
commit c08531a630
3861 changed files with 1962946 additions and 270 deletions
@@ -1161,7 +1161,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
async openFile(pdfString, filename, type) {
const modal = await this.modalController.create({
/* const modal = await this.modalController.create({
component: ViewDocumentSecondOptionsPage,
componentProps: {
fileUrl: pdfString,
@@ -1169,8 +1169,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
},
cssClass: 'modal modal-desktop'
});
await modal.present();
/* const blob = this.b64toBlob(pdfString, type)
await modal.present(); */
const blob = this.b64toBlob(pdfString, type)
let pathFile = ''
const fileName = filename
const contentFile = blob
@@ -1180,17 +1180,23 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
pathFile = this.file.externalRootDirectory
}
console.log('file data', pdfString)
console.log(pathFile)
let removePre = this.removeTextBeforeSlash(pdfString,',')
console.log('file data remove ', removePre)
await Filesystem.writeFile({
path: fileName,
data: pdfString,
directory: Directory.Data,
data: removePre,
directory: Directory.Cache,
}).then((dir) => {
console.log('DIR ', dir)
this.fileOpener
.open(dir.uri, type)
.then(() => console.log())
.catch(e => console.error(e))
}); */
});
}
downloadFileMsg(msg: MessageService) {
@@ -1327,6 +1333,16 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
reject(error);
};
});
}
removeTextBeforeSlash(inputString, controlString) {
if (inputString.includes(controlString)) {
const parts = inputString.split(controlString);
return parts.length > 1 ? parts[1] : inputString;
} else {
return inputString;
}
}
}
+6 -6
View File
@@ -857,7 +857,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log('ios add file ')
const resultt = await FilePicker.pickFiles({
types: ['application/pdf'],
types: ['application/pdf', 'application/doc', 'application/docx','application/xls', 'application/xlsx', 'application/ppt',
'application/pptx', 'application/txt'],
multiple: false,
readData: true,
});
@@ -1118,7 +1119,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log('url while open ',pdfString)
const modal = await this.modalController.create({
/* const modal = await this.modalController.create({
component: ViewDocumentSecondOptionsPage,
componentProps: {
fileUrl: pdfString,
@@ -1126,8 +1127,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
},
cssClass: 'modal modal-desktop'
});
await modal.present();
/*
await modal.present(); */
var blob = new Blob([pdfString], { type: 'application/pdf' });
console.log('blob blob', blob)
@@ -1156,7 +1157,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
path: fileName,
data: removePre,
directory: Directory.Cache,
encoding: Encoding.UTF8
}).then((dir) => {
console.log('DIR ', dir)
this.fileOpener
@@ -1165,7 +1165,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
.catch(e => console.error(e))
}).catch((error) => {
console.log('error writing the file', error)
}); */
});
}
removeTextBeforeSlash(inputString, controlString) {