mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
document preview working
This commit is contained in:
@@ -29,7 +29,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
|
||||
@@ -1106,11 +1106,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
async openFile(pdfString, filename, type) {
|
||||
const blob = this.b64toBlob(pdfString, type)
|
||||
console.log(blob)
|
||||
let pathFile = ''
|
||||
const fileName = filename
|
||||
const contentFile = blob
|
||||
if (this.platform.is('ios')) {
|
||||
pathFile = this.file.documentsDirectory
|
||||
} else {
|
||||
@@ -1122,13 +1119,16 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
await Filesystem.writeFile({
|
||||
path: fileName,
|
||||
data: pdfString,
|
||||
directory: Directory.Data,
|
||||
directory: Directory.Cache,
|
||||
encoding: Encoding.UTF8,
|
||||
}).then((dir) => {
|
||||
console.log('DIR ', dir)
|
||||
this.fileOpener
|
||||
.open(dir.uri, type)
|
||||
.then(() => console.log())
|
||||
.catch(e => console.error(e))
|
||||
}).catch((error) => {
|
||||
console.log('error writing the file', error)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -448,6 +448,8 @@ export class MessageService {
|
||||
let downloadFile = "";
|
||||
this.AttachmentsService.downloadFile(this.file.guid).subscribe(async (event) => {
|
||||
|
||||
console.log('download file',event)
|
||||
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
@@ -456,6 +458,7 @@ export class MessageService {
|
||||
} else if (this.file.type != "application/img") {
|
||||
|
||||
downloadFile = new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '');
|
||||
console.log('downloaded file', downloadFile)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user