Danyal
Danyal

Reputation: 458

filetransfer download phonegap issue

Tried to download file using Filetransfer phonegap for android

But the file cannot be downloaded bacause of download error(error code = 1 i.e FileError.NOT_FOUND_ERR)

The following is the code : (where url is http://samplepdf.com/sample.pdf)

function downloadImage(url,fileName){
    var fileTransfer = new FileTransfer();
    fileTransfer.download(
        url,
        window.rootFS.fullPath+ "/" + fileName,
        function(entry) {
            alert("download complete: " + entry.fullPath);
        },
        function(error) {
            alert("download error"+JSON.stringify(error));
        }
    );
}
  1. Checked that window.rootFS.fullPath+ "/" + fileName gives /mnt/sdcard/myFileName. Tried to change fullpath by only using directory name(i.e /mnt/sdcard) but still no use, same error.

  2. The error is that the file does not exist but it does.(You can see that by going to the above samplepdf link).

  3. Also i have allowed all url access in the res/xml/ in android.

  4. Strangely the JSON error object string gives HTTP status as 200(success) .

    Could anyone suggest where the issue could be, or solve it :)?

Upvotes: 3

Views: 2029

Answers (1)

Danyal
Danyal

Reputation: 458

The issue was with the permissions in android. Added the following in the manifest file

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Upvotes: 2

Related Questions