Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why doesn't it work for me? #309

Open
massimilianocom opened this issue Sep 7, 2021 · 1 comment
Open

Why doesn't it work for me? #309

massimilianocom opened this issue Sep 7, 2021 · 1 comment

Comments

@massimilianocom
Copy link

I did a simple copy and paste:

`var fileTransfer = new FileTransfer();
var uri = encodeURI("https://www.radiomatese.it/Download/RadioMatese.apk");
var fileURL = "cdvfile://localhost/persistent/path/to/downloads/";

fileTransfer.download(
    uri,
    fileURL,
    function(entry) {
        console.log("download complete: " + entry.toURL());
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("download error code" + error.code);
    },
    false, {
        headers: {
            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
        }
    }
);`

But it doesn't matter what am I wrong?

@breautek
Copy link
Contributor

breautek commented Sep 24, 2021

Try using cordova.file.* constants instead of the cdvfile urls.

Note that the currently released version of this plugin is still an old version that was released before this plugin was revived. The development version (in github master branch) contains several fixes that you may need for the plugin to be usable.

There are problems with cdvfile: urls on WKWebView on iOS, and now with WebAssetLoader used on cordova-android >= 10. Despite the file transfer documentation still using them in it's examples, cdvfile support may be dropped, (iOS schemes and Android's WebAssetLoader kinda makes them obsolete anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants