El-Tommy opened a new issue, #1590:
URL: https://github.com/apache/cordova-android/issues/1590

   I'm using JavaScript's FileReader API to try to get the blob of a file 
inside a Cordova application.
   
   My code is like the example below:
   
   ```javascript
   originalLocation = 
'content://com.android.externalstorage.documents/document/primary%3ADownload%2F1671641692909.jpg';
   
   window.FilePath.resolveNativePath(originalLocation, function (newFilepath) { 
resolveFilePath(newFilepath) });
   
   function resolveFilePath(location) {
       window.resolveLocalFileSystemURL(location, function (fileEntry) {
   
           fileEntry.file(function (file) {
   
               let reader = new FileReader();
   
               reader.onload = function (event) {
                   console.log(reader.result);
                   console.log(event);
               }
               reader.onloadstart = function (event) {
                   console.log(reader.result);
                   console.log(event);
               }
               reader.onloadend = function (event) {
                   console.log(reader.result);
                   console.log(event);
               }
               reader.onprogress = function (event) {
                   console.log(reader.result);
                   console.log(event);
               }
               reader.onerror = function (event) {
                   console.log(reader.result);
                   console.log(event);
                   const error = reader.error;
                   console.log(error);
               }
               reader.onabort = function (event) {
                   console.log(reader.result);
                   console.log(event);
               }
               console.log(file);
               reader.readAsArrayBuffer(file);
           });
       });
   }
   ```
   
   ```xml
   <edit-config file="AndroidManifest.xml" mode="merge" 
target="/manifest/application">
          <application requestLegacyExternalStorage="true" />
   </edit-config>
   
   <preference name="AndroidExtraFilesystems" 
value="files,files-external,documents,sdcard,cache,cache-external,assets,root" 
/>
   <preference name="AndroidPersistentFileLocation" value="Internal" />
   <preference name="AndroidPersistentFileLocation" value="Compatibility" />
   ```
   
   When reading an image, the API works correctly, obtaining the content, but 
with files that are not images, the FileReader's onerror event always returns 
the message "FileError {code: 1}". I already tried to read using all possible 
ways (readAsArrayBuffer, readAsBinaryString, readAsDataURL,readAsText).
   
   The location of files on the smartphone.
   
   - Image before resolveLocalFileSystemURL: 
`content://com.android.externalstorage.documents/document/primary%3ADownload%2F1671641692909.jpg`
   - Image after resolveLocalFileSystemURL: 
`https://com.example.mobile.app.myapp/__cdvfile_sdcard__/Download/1671641692909.jpg
 - Success`
   - File before resolveLocalFileSystemURL: 
`content://com.android.externalstorage.documents/document/primary%3ADownload%2FExample.pptx`
   - File after resolveLocalFileSystemURL: 
`https://com.example.mobile.app.myapp/__cdvfile_sdcard__/Download/Example.pptx 
- Error`
   
   What could possibly be happening?
   
   ### Environment, Platform, Device
   Android 12 - Samsung A 53
   
   ### Version information
   Cordova: 11.1.0
   Cordova-Android:  10.1.2
   
   ## Checklist
   
   - [X] I searched for existing GitHub issues
   - [X] 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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to