breautek commented on issue #303:
URL: 
https://github.com/apache/cordova-plugin-file/issues/303#issuecomment-1357071398

   With Android's scoped storage model enforced in API 30, your application my 
write to external directory but may not overwrite files that other apps have 
created/written to.
   
   Additionally, custom directories inside the external storage is now 
forbidden, only the predefined directories (e.g. `Download`, `Documents`, etc) 
can be written to. The `externalRootDirectory` is also not a writable path 
anymore.
   
   An example of a working test app can be found:
   
   ```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! from app 1'], { 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();
   }
   ```
   
   Closing this issue as not a bug. However if you think you have foound a bug, 
please create a new issue with the issue form filled out. Alternatively support 
questions can be asked on our [Discussions 
board](https://github.com/apache/cordova/discussions).


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