cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cordova-plugin-file] caleb87 opened a new issue #396: Android works, but iOS 13.5.1 returns error code 1
Date Fri, 05 Jun 2020 16:51:57 GMT

caleb87 opened a new issue #396:
URL: https://github.com/apache/cordova-plugin-file/issues/396


   # Bug Report
   Reading a file works on Android. It fails on iOS 13.5.1 with error code 1. 
   
   The code I'm using:
   ```
   function getLocalFile(url, cb) {
   	console.log("ATTEMPTING TO LOAD: ",cordova.file.applicationDirectory + "www/"+url);
   	window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/"+url, function(fileEntry)
{
   		console.log(fileEntry);
   		fileEntry.file(function(file) {
   			var s = "";
   			s += "<b>name:</b> " + file.name + "<br/>";
   			s += "<b>localURL:</b> " + file.localURL + "<br/>";
   			s += "<b>type:</b> " + file.type + "<br/>";
   			s += "<b>lastModifiedDate:</b> " + (new Date(file.lastModifiedDate)) + "<br/>";
   			s += "<b>size:</b> " + file.size + "<br/>";
   			console.log(s);
   			var reader = new FileReader();
   			reader.onloadend = function() {
   				var fileContents = this.result;
   				console.log("Successful file read: "+fileContents);
   				if(cb) cb(fileContents);
   			};
   			reader.readAsText(file);
   		});
   	}, function(err) {
   		console.log("File failed ", err);
   		console.dir(err);
   	});
   }
   ```
   
   Also works on Android, but fails on iOS:
   ```
   function getLocalFile(url, cb) {
   	
   	resolveLocalFileSystemURL(cordova.file.applicationDirectory, function(entry) {
   		console.log("Success! Got a app dir");
   		console.log(entry);
   		var nativeURL = entry.nativeURL;
   		console.log("NATIVE URL IS ",nativeURL);
   
   		console.log("ATTEMPTING TO LOAD: ",nativeURL + "www/"+url);
   		window.resolveLocalFileSystemURL(nativeURL + "www/"+url, function(fileEntry) {
   			console.log("FILE ENTRY INFORMATION IS: ");
   			console.log(fileEntry);
   			fileEntry.file(function(file) {
   				var s = "";
   				s += "<b>name:</b> " + file.name + "<br/>";
   				s += "<b>localURL:</b> " + file.localURL + "<br/>";
   				s += "<b>type:</b> " + file.type + "<br/>";
   				s += "<b>lastModifiedDate:</b> " + (new Date(file.lastModifiedDate)) +
"<br/>";
   				s += "<b>size:</b> " + file.size + "<br/>";
   				console.log(s);
   				var reader = new FileReader();
   				reader.onloadend = function() {
   					var fileContents = this.result;
   					console.log("Successful file read: "+fileContents);
   					if(cb) cb(fileContents);
   				};
   				reader.readAsText(file);
   			});
   		}, function(err) {
   			console.log("File failed ################# ", err);
   			console.dir(err);
   		});
   		
   		
   	}, function(error) {
   		console.error("Something bad happened, and we didn't get a app dir");
   	});
   	
   	
   }
   ```
   
   ### What is expected to happen?
   Both platforms return same result.
   
   
   ### What does actually happen?
   Returns error code 1. 
   
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the
issue? -->
   Physical iPhone X, iOS 13.5.1
   
   
   
   ### Version information
   
   cordova-plugin 6.0.2
   Phonegap 9
   iOS 13.5.1
   Xcode for building
   
   
   
   
   
   ## 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.

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


Mime
View raw message