El-Tommy commented on issue #565:
URL: 
https://github.com/apache/cordova-plugin-file/issues/565#issuecomment-1762495282

   @etcho,
   pt-BR: Eu vou postar todo o meu código desde a parte que o app dispara a 
escolha de arquivos. Dependendo do local ou gerenciador de arquivos usados no 
Android, ele pode apresentar problema. É uma confusão.
   
   en-US: _I'm going to post all my code from the part where the app triggers 
the choice of files. Depending on the location or file manager used on Android, 
it may have problems. It's a mess._
   
   
   ```
   fileChooser.open($scope.selectFileAndUpload, error);
   
   $scope.selectFileAndUpload = function (data) {
       var location;
   
       if (data.url === undefined) {
           location = data;
       } else {
           location = data.url;
       }
   
       if (location.indexOf('content://') === 0) {
   
           window.FilePath.resolveNativePath(location, function (newFilepath) {
               resolveFilePath(newFilepath);
           }, function (error) {
               if (error.code === 0) {
                   console.log('Não foi possível ler este arquivo.')
               } else if (error.code === 1) {
                   console.log('Problema no Google Drive.',) 
               }
           });
       } else {
           resolveFilePath(location);
       }
   
   }
   
   function resolveFilePath(location) {
       window.resolveLocalFileSystemURL(location, function (fileEntry) {
   
           fileEntry.file(function (file) {
   
               let fileType = file.type;
   
               let reader = new FileReader();
   
               reader.onloadend = function (e) {
                   let imgBlob = new Blob([this.result], { fileType });
   
                   $scope.filesToUpload.forEach(element => {
                       if (element.url === location) {
                           element.blob = imgBlob;
                       }
                   });
   
               }
   
           }, function () {
               console.log('Ocorreu um erro ao ler o arquivo.');
           });
       }, function (e) {
           console.log('Ocorreu um erro ao ler o arquivo.');
       });
   }
   ```


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

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

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


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

Reply via email to