You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/12/12 03:49:55 UTC

[GitHub] [cordova-plugin-file-transfer] rolinger opened a new issue #296: Error in success callbackID on iOS

rolinger opened a new issue #296:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/296


   # Bug Report
   File is successfully downloading but getting an error the success callback
   
   ## Problem
   ```
   [{"isFile":false,"isDirectory":true,"name":"","fullPath":"/","filesystem":"<FileSystem: library-nosync>","nativeURL":"file:///var/mobile/Containers/Data/Application/900BE112-444C-4F33-84AF-F745E8EE0C91/Library/NoCloud/"}]
   [{"isFile":false,"isDirectory":true,"name":"download","fullPath":"/download/","filesystem":"<FileSystem: library-nosync>","nativeURL":"file:///var/mobile/Containers/Data/Application/900BE112-444C-4F33-84AF-F745E8EE0C91/Library/NoCloud/download/"}]
    pathB1: file:/var/mobile/Containers/Data/Application/900BE112-444C-4F33-84AF-F745E8EE0C91/Library/NoCloud/download/Word1.DOC
   File Transfer downloading file...
   [CDVFileTransferDelegate connection:didReceiveResponse:] [Line 771] Streaming to file /var/mobile/Containers/Data/Application/900BE112-444C-4F33-84AF-F745E8EE0C91/Library/NoCloud/download/Word1.DOC
   File Transfer Finished with response code 200
   [CDVFileTransferDelegate connectionDidFinishLoading:] [Line 637] File Transfer Download success
   Error in Success callbackId: FileTransfer1502202275 : TypeError: null is not an object (evaluating 'result.lengthComputable')
   win@ionic://myApp/plugins/cordova-plugin-file-transfer/www/FileTransfer.js:202:26
   callbackFromNative@ionic://attendago/cordova.js:295:63
   ionic://myApp/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35
   promiseReactionJob@[native code]
   ```
   
   
   ### What is expected to happen?
   Its supposed to cleanly download the file.
   
   
   ### What does actually happen?
   The above error is thrown, the file can't be found anywhere in iOS folders and the app page breaks because the JS error was thrown.
   
   
   ### Command or Code
   Here is the code I am using to download the file.  It all works just fine on Android, but not on iOS.  I am using the `codorva-plugin-file-downloader` plugin which is a wrapper that uses this plugin.  The error being thrown is from this plugin.
   ```
   $scope.downloadLink = function(fileInfo) {
       if (fileInfo.cType == 2) {
          var dir = "images" ;
       } else {
         var dir = "docs" ;
       }
       var urlFile = "https://portal.attendago.com/files/C" +fileInfo.cID+ "/" +dir+ "/" + fileInfo.cfInfo ;
       var newFileName = fileInfo.cfName+ "." +fileInfo.cfExt ;
       let storage_location = '' ;
   
       if (ionic.Platform.isIOS()) {
          //storage_location = cordova.file.documentsDirectory ;
          storage_location = cordova.file.dataDirectory ;
       } else if (ionic.Platform.isAndroid()) {
          storage_location = 'file:///storage/emulated/0/' ;
       }
       let downloading = function(event) {
         var data = event.data ;
         if (data[0] != 100) {
           var msg = "Downloading file: " +data[0]+ "%" ;
           var color = "red" ;
         } else {
           var msg = "DOWNLOAD COMPLETE!" ;
           var color = "green" ;
         }
         $scope.startStatus(fileInfo.cfID,color,msg) ;
       }
       let downloaded = function(event) {
         setTimeout(function() {
           $scope.endStatus(fileInfo.cfID) ;
           event.target.removeEventListener(event.name,downloaded) ;
         },5000) ;
       }
       let initialized = function(event) {
         downloader.get(urlFile,null,newFileName) ;
         event.target.removeEventListener(event.name,initialized) ;
       } ;
       document.addEventListener('DOWNLOADER_initialized', initialized) ;
       document.addEventListener('DOWNLOADER_downloadProgress',downloading) ;
       document.addEventListener('DOWNLOADER_downloadSuccess', downloaded) ;
       document.addEventListener('DOWNLOADER_gotFileSystem', function() {
         console.log(event.data) ;
       }) ;
       document.addEventListener('DOWNLOADER_gotFolder', function() {
         console.log(event.data) ;
       }) ;
       downloader.init({folder: 'download', fileSystem: storage_location})
     }
   ```
   
   
   ### Environment, Platform, Device
   iPhone 7, iOS 14.1
   
   
   ### Version information
   ```
   Ionic:
   
      Ionic CLI         : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
      Ionic Framework   : ionic1 1.0.0
      @ionic/v1-toolkit : 1.0.22
   
   Cordova:
   
      Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
      Cordova Platforms : ios 5.1.1
      Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 32 other plugins)
   
   Utility:
   
      cordova-res (update available: 0.15.2) : 0.15.1
      native-run (update available: 1.3.0)   : 1.2.2
   
   System:
   
      ios-deploy : 1.10.0
      ios-sim    : 8.0.2
      NodeJS     : v10.21.0 (/usr/local/Cellar/node@10/10.21.0/bin/node)
      npm        : 6.14.4
      OS         : macOS Catalina
      Xcode      : Xcode 12.1 Build version 12A7403
   ```
   
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x ] I searched for existing GitHub issues
   - [ ] I updated all Cordova tooling to most recent version
   - [x ] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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