You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/06/25 02:46:37 UTC

[GitHub] [cordova-plugin-file] gmoraiz opened a new issue, #527: Error 9 when trying to save a file on android 10 folder Download

gmoraiz opened a new issue, #527:
URL: https://github.com/apache/cordova-plugin-file/issues/527

   # Bug Report
   When I try to save a file in the download/documents folder (on a mobile with android 10), the following error occurs: 
   `FileErrorĀ {code: 9}`
   The strange thing is that on android 11 and 12 it works, on 9, 8 and 7 too...
   
   
   ### Version information
   android-targetSdkVersion: 30
   android-minSdkVersion: 19
   cordova-plugin-file: 7.0.0
   cordova: 10
   device: Galaxy Nexus API 29 Android
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [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: issues-unsubscribe@cordova.apache.org.apache.org

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


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


[GitHub] [cordova-plugin-file] breautek closed issue #527: Error 9 when trying to save a file on android 10 folder Download

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek closed issue #527: Error 9 when trying to save a file on android 10 folder Download
URL: https://github.com/apache/cordova-plugin-file/issues/527


-- 
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-unsubscribe@cordova.apache.org

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


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


[GitHub] [cordova-plugin-file] breautek commented on issue #527: Error 9 when trying to save a file on android 10 folder Download

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #527:
URL: https://github.com/apache/cordova-plugin-file/issues/527#issuecomment-1402873214

   The bug is with API 29 not supporting filesystem access via Filesystem APIs. This was fixed in API 30.
   
   > To help your app work more smoothly with third-party media libraries, Android 11 allows you to use APIs other than the [MediaStore](https://developer.android.com/reference/android/provider/MediaStore) API to access media files from shared storage using [direct file paths](https://developer.android.com/training/data-storage/shared/media#direct-file-paths).
   
   https://developer.android.com/about/versions/11/privacy/storage
   
   Unfortunately from a filesystem plugin standpoint, there is nothing we can do to work around this bug.
   
   From an application standpoint, using a [MediaStore](https://www.npmjs.com/search?q=ecosystem%3Acordova%20mediastore) plugin may be a workaround.


-- 
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-unsubscribe@cordova.apache.org

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


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


[GitHub] [cordova-plugin-file] breautek commented on issue #527: Error 9 when trying to save a file on android 10 folder Download

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #527:
URL: https://github.com/apache/cordova-plugin-file/issues/527#issuecomment-1357037938

   The following code works for me assuming that my app has ownership of the file (e.g. the file wasn't written by another app)
   
   ```javascript
   document.addEventListener('deviceready', onDeviceReady, false);
   
   var testFiles = async function() {
       window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory + 'Download', (downloadsDirEntry) => {
           console.log('DOWNLOADS', downloadsDirEntry);
           downloadsDirEntry.getFile('test1.txt', { create: true }, (fileEntry) => {
               fileEntry.createWriter((writer) => {
                   writer.onwriteend = () => {
                       console.log('file written');
                   };
   
                   writer.onerror = (error) => {
                       console.error('WRITE ERROR', error);
                   };
   
                   writer.write(new Blob(['Hello!'], { type: 'text/plain'}));
               });
           }, (error) => {
               console.error('FILE OPEN', error);
           })
       }, (error) => {
           console.error('DIR READ', error);
       });
   };
   
   function onDeviceReady() {
       // Cordova is now initialized. Have fun!
   
       console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
       document.getElementById('deviceready').classList.add('ready');
   
       testFiles();
   }
   ```
   
   The above code writes the file and can be observed by using `adb pull /storage/emulated/0/Download/test1.txt ./` that both the file exists and contains the contents written.
   
   Tested against target API 32 / API 32 emulator. Can you please compare, or share some code that reproduces the issue?


-- 
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-unsubscribe@cordova.apache.org

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


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