cordova-plugin-file-transfer icon indicating copy to clipboard operation
cordova-plugin-file-transfer copied to clipboard

Why doesn't it work for me?

Open massimilianocom opened this issue 3 years ago • 1 comments

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?

massimilianocom avatar Sep 07 '21 08:09 massimilianocom

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).

breautek avatar Sep 24 '21 00:09 breautek