cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "joanebrown (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-11669) $cordovaFileTransfer.download returns "null" always
Date Thu, 04 Aug 2016 16:14:20 GMT

     [ https://issues.apache.org/jira/browse/CB-11669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

joanebrown updated CB-11669:
----------------------------
    Description: 
When I use the next code I always get this error:

*ERROR:*
{quote}
{"code":null,"source":null,"target":null,"http_status":null,"body"
:null,"exception":null}{quote}


*CODE:*
{quote}
          var url = "http://foo.bar/img/image.png";
         var filename = url.split("/").pop();
         var targetPath = cordova.file.externalRootDirectory + 'Pictures/' + filename;


         console.log(filename); // returns "image.png"
         console.log(targetPath); // returns "file:///storage/emulated/0/Pictures/image.png"

            $cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result)
{
                  console.log(JSON.stringify(result));
                  $scope.hasil = 'Save file on '+targetPath+' success!';
                  $scope.mywallpaper=targetPath;
            }, function (error) {
/* return {"code":null,"source":null,"target":null,"http_status":null,"body"
:null,"exception":null}*/
                  console.log(JSON.stringify(error));
                  $scope.hasil = 'Error Download file';
            }, function (progress) {
                  $scope.downloadProgress = (progress.loaded / progress.total) * 100;
            });

{quote}

  was:
When I use the next code I always get this error:

*ERROR:*

{"code":null,"source":null,"target":null,"http_status":null,"body"
:null,"exception":null}


*CODE:*
{quote}
          var url = "http://foo.bar/img/image.png";
         var filename = url.split("/").pop();
         var targetPath = cordova.file.externalRootDirectory + 'Pictures/' + filename;


         console.log(filename); // returns "image.png"
         console.log(targetPath); // returns "file:///storage/emulated/0/Pictures/image.png"

            $cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result)
{
                  console.log(JSON.stringify(result));
                  $scope.hasil = 'Save file on '+targetPath+' success!';
                  $scope.mywallpaper=targetPath;
            }, function (error) {
/* return {"code":null,"source":null,"target":null,"http_status":null,"body"
:null,"exception":null}*/
                  console.log(JSON.stringify(error));
                  $scope.hasil = 'Error Download file';
            }, function (progress) {
                  $scope.downloadProgress = (progress.loaded / progress.total) * 100;
            });

{quote}


> $cordovaFileTransfer.download returns "null" always
> ---------------------------------------------------
>
>                 Key: CB-11669
>                 URL: https://issues.apache.org/jira/browse/CB-11669
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 5.0.0
>         Environment: ionic
>            Reporter: joanebrown
>              Labels: filetransfer, ionic
>
> When I use the next code I always get this error:
> *ERROR:*
> {quote}
> {"code":null,"source":null,"target":null,"http_status":null,"body"
> :null,"exception":null}{quote}
> *CODE:*
> {quote}
>           var url = "http://foo.bar/img/image.png";
>          var filename = url.split("/").pop();
>          var targetPath = cordova.file.externalRootDirectory + 'Pictures/' + filename;
>          console.log(filename); // returns "image.png"
>          console.log(targetPath); // returns "file:///storage/emulated/0/Pictures/image.png"
>             $cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result)
{
>                   console.log(JSON.stringify(result));
>                   $scope.hasil = 'Save file on '+targetPath+' success!';
>                   $scope.mywallpaper=targetPath;
>             }, function (error) {
> /* return {"code":null,"source":null,"target":null,"http_status":null,"body"
> :null,"exception":null}*/
>                   console.log(JSON.stringify(error));
>                   $scope.hasil = 'Error Download file';
>             }, function (progress) {
>                   $scope.downloadProgress = (progress.loaded / progress.total) * 100;
>             });
> {quote}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message