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 2020/07/30 11:18:18 UTC

[GitHub] [cordova-plugin-file] peterfox1 edited a comment on issue #408: Platform android@9.0.0 running on Android 10 : getFile produces INVALID_MODIFICATION_ERR - Error code 9.

peterfox1 edited a comment on issue #408:
URL: https://github.com/apache/cordova-plugin-file/issues/408#issuecomment-666302030


   Gave it a go saving to another location to see if it would get around that permission, seems like saving to the app data directory `cordova.file.dataDirectory` works.
   
   `fileSystem.root` seems to be outside of the app data perhaps? - I didn't realise this since the docs say "fs.root is a DirectoryEntry object that represents the persistent storage in the sandboxed file system."
   
   Also noticed:
   - If the file was created by the API 28 app, the API 29 app seems to be able to write to it, it just can't create new files.
   - Using `requestFileSystem(window.TEMPORARY` seems to work.
   
   In case it's useful for anyone else that only needs to store files in the app dir, the change to use `cordova.file.dataDirectory` is:
   
   ```js
   window.resolveLocalFileSystemURL(cordova.file.dataDirectory,	// <-----------
   	function (dirEntry) {	// <-----------
   		
   		dirEntry.getFile("test2.txt", {create: true, exclusive: false},	// <-----------
   			function(fileEntry) {	// File loaded/created
   				
   				fileEntry.createWriter(
   					function(writer) {	// Writer created
   						
   						writer.write('hello');
   						console.log('test2 it worked!');
   						
   					},
   					function(error) {	// Writer failure
   						console.log('createWriter', error);
   					}
   				);
   				
   			},
   			function(error) {	// File failure
   				console.log('getFile', error);
   			}
   		);
   	
   	},
   	function(error) { console.log('resolveLocalFileSystemURL', error); }
   );
   ```


----------------------------------------------------------------
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: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org