Cannot open files with FileOpener2, but not getting an error in Android

[postlink] https://the-best-way-of-life-is-islam.blogspot.com/2015/07/cannot-open-files-with-fileopener2-but.html [/postlink]

I am attempting to open a PDF file with FileOpener2 (through ng-cordova) with the following code:

$cordovaFile.checkFile(cordova.file.dataDirectory, attachmentPath)
    .then((fileEntry) => {
        // success
        fileEntry.getMetadata((metadata) => {
            // metadata.size is in bytes
            var megabyteSize = metadata.size / 1048576;

            if (megabyteSize > 5) {
                var path = cordova.file.dataDirectory + attachmentPath;
                console.log(path); // prints: file:///data/data/com.ionicframework.enhatch146189/files/attachments/CS-353ES_CS-420ES_Eng.pdf which is correct

                $cordovaFileOpener2.open(path, 'application/pdf').then(() => {
                    console.log("Opened!") // prints
                }, (error) => {
                    console.log(error);
                    usePDFJs(); // tries to render PDF in app with PDFJs
                });
            } else {
                usePDFJs();
            }
        })
    }, function (error) {
        // error
        console.error(error);
    });

What happens confuses me: it prompts me with an "open this file in Adobe Reader?" and lists the other PDF viewers, and the console prints "Opened!"

However, no matter what I open ANY pdf in, I get some sort of error such as "cannot open this PDF file".

Can anyone see something wrong with this code?

اذا أعجبك الموضوع ساهم في نشره :

Enregistrer un commentaire

 
حقوق النشر: Published by | Template Created by | القناة على اليوتيب
copyright © 2014. The Best Way Of Life Is Islam -يمكن نقل كل ما هو موجود في موقع الرحمة تيوب
القرآن الكريم و الأحاديث النبوية أناشيد و دروس اسلامية منوعة موقع الفيديوهات الاسلامية
تطوير و تعريب مدونة ثعلوب