mostafa-mansour1 / previewAnyFile

Cordova Plugin to preview any file in native mode by providing the local or external URL
MIT License
33 stars 31 forks source link

previewPath function doesn't seem to be compatible with Cordova #41

Open christian-kolb opened 2 years ago

christian-kolb commented 2 years ago

For some reason only preview works but previewPath does not. When I use previewPath I get the following error:

Unhandled Promise Rejection: Error: The old format of this exec call has been removed (deprecated since 2.1). Change to: cordova.exec(null, null, 'Service', 'action', [ arg1, arg2 ]);

I'm using the latest version (0.2.9) with Capacitor 3 and Ionic @ionic-native/core 5.36.0 (I don't know if that's relevant).

Let me know if you need any more information for reproduction or when I can test something for you 🙂

sharkdong commented 2 years ago

the same error , I don't know how to sollution this question

mostafa-mansour1 commented 2 years ago

don't use ionic wrapper, use it directly like

  window.PreviewAnyFile.previewPath(
        win =>
            {
                if (win == "SUCCESS") {
                    console.log('success')
                } else if (win == "CLOSING") {
                    console.log('closing')
                } else if (win == "NO_APP") {
                    console.log('no suitable app to open the file (mainly will appear on android')
                } else {
                    console.log('error')
                }
            },
        error => console.error("open failed", error),
        "file://filepath/filename.ext"
    );
vochitan90 commented 1 year ago

Hi @mostafa-mansour1

Today I try to use previewPath in ionic capacitor to open an external pdf file via a link - the message return success but it can not preview the file :(

My code look like this:

public async previewFile(): Promise<void> {
        await this.loadingService.presentLoader('Loading...');

        this.documentService
            .previewPath('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf', {
                name: 'tan_vo.pdf',
                mimeType: 'application/pdf'
            })
            .subscribe((res) => {
                console.log(res);
                this.loadingService.dismissLoader();
            });
    }

and the result:

image

mostafa-mansour1 commented 1 year ago

I see the link is not a direct link to the file It redirects you to

https://file-examples.com/storage/febd341d226359c2099c083/2017/10/file-sample_150kB.pdf [X] file-sample_150kBhttps://file-examples.com/storage/febd341d226359c2099c083/2017/10/file-sample_150kB.pdf PDF Document · 143 KBhttps://file-examples.com/storage/febd341d226359c2099c083/2017/10/file-sample_150kB.pdf

The plugin cannot do a redirect

Regards,


Mostafa Mansour Software Engineer 00971 524988466

On 27 Oct 2022, at 4:59 PM, Tan Vo @.***> wrote:



Hi @mostafa-mansour1https://github.com/mostafa-mansour1

Today I try to use previewPath in ionic capacitor to open an external pdf file via a link - the message return success can not preview the file :(

My code look like this:

public async previewFile(): Promise { await this.loadingService.presentLoader('Loading...');

    this.documentService
        .previewPath('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf', {
            name: 'tan_vo.pdf',
            mimeType: 'application/pdf'
        })
        .subscribe((res) => {
            console.log(res);
            this.loadingService.dismissLoader();
        });
}

and the result:

[image]https://user-images.githubusercontent.com/8901498/198290937-4d057d09-2786-4952-928a-65ffcc61e642.png

— Reply to this email directly, view it on GitHubhttps://github.com/mostafa-mansour1/previewAnyFile/issues/41#issuecomment-1293489893, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABSFOB2HAZEKNVHOMXZZU4LWFJ4B7ANCNFSM5H2A2XQQ. You are receiving this because you were mentioned.Message ID: @.***>

vochitan90 commented 1 year ago

Hi @mostafa-mansour1

Thank you for your answer.

I manage to preview the pdf file via a new link https://www.africau.edu/images/default/sample.pdf

When I read the document, you mentioned about your pull request didn't merge yet and need to copy after install the link since 02.02 -> So did you merge it?

image

Also please update the link (How to use in ionic project) -> PAGE NOT FOUND

mostafa-mansour1 commented 1 year ago

I didn’t merge it Will do soon

Regards,


Mostafa Mansour Software Engineer 00971 524988466

On 27 Oct 2022, at 5:22 PM, Tan Vo @.***> wrote:



Hi @mostafa-mansour1https://github.com/mostafa-mansour1

Thank you for your answer.

I manage to preview the file pdf file via a new link https://www.africau.edu/images/default/sample.pdf

When I read the document, you mentioned about your pull request didn't merge yet and need to copy after install the link since 02.02 -> So did you merge it?

[image]https://user-images.githubusercontent.com/8901498/198295592-8a8056da-da67-4f37-80a6-948ea2efb1e2.png

Also please update the link (How to use in ionic project) -> PAGE NOT FOUND

— Reply to this email directly, view it on GitHubhttps://github.com/mostafa-mansour1/previewAnyFile/issues/41#issuecomment-1293519856, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABSFOB2ZXRITK7YTLFS4VEDWFJ6Y5ANCNFSM5H2A2XQQ. You are receiving this because you were mentioned.Message ID: @.***>