title: Downloading a pdf blob to device in Cordova Android App
body: <p>I am working on a program where I want to save a pdf blob in a android device.
  This is server side code inside a callback which receives pdf data as 'result'.</p>
  
  <pre><code>var file = new Blob([result.data], {
            type: 'application/pdf;charset=utf-8;'
          }); 
          return file;
        });
  </code></pre>
  
  <p>At client side, the following code works in chrome debugging browser and pdf is successfully downloaded. However on device I get the following error :</p>
  
  <pre><code> 11-18 18:13:27.255 10504-10707/? D/FileTransfer: download blob:file:///e9088aac-8525-4071-9280-164a6e15c22e to file:///storage/emulated/0/Download/loanContract_11-10-2016_9-29-59-715.pdf
   11-18 18:13:27.255 10504-10707/? E/FileTransfer: Unsupported URI: blob:file:///e9088aac-8525-4071-9280-164a6e15c22e
  </code></pre>
  
  <p>Here the data in window.URL.createObjectURL(data) is the file blob returned by server. <a href="https://stackoverflow.com/questions/34356724/">Phonegap/Cordova 3.6 - Download of file through blob:file</a>  didnt help me in solving the problem.</p>
  
  <pre><code>var fileURL = window.URL.createObjectURL(data);
                      $scope.content = data;
                      a.href = fileURL;
                      a.download = fileName;
                      a.click();
                      console.log("Inside parent function");
                      $scope.fileName = fileName;
  
  window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, function (dirEntry) {                   
                  download($scope.fileURL, dirEntry.toURL()+'Download/'+ $scope.fileName) ;
               }, function () {} );
  
  
    var download = function ( uri, fileURL) {
          $cordovaFileTransfer.download(
              uri,
              fileURL,
              function (success) {
                  console.log(success);
              },
              function (err) {
                  console.log(err);
              }, true)
      };
  </code></pre>
  
  <p>If i give a url which sends a pdf file as HTTP response and I provide the API's URL as the parameter uri to cordovaFileTransfer.download, then the pdf gets saved.
  Kindly help me saving this bob as a pdf on the device.</p>