CordovaFile folder structure query

Hi, I have the below piece of code to create a folder then download a file in to this folder. The alert runs that the folder is created but the download fails with the below error:

2014-11-12 11:53:07.785 [29648:410135] FileTransferError {
body = “Could not create path to save downloaded file: The operation couldn\U2019t be completed. (Cocoa error 513.)”;
code = 1;
“http_status” = 200;
source = “https://angularjs.org/img/AngularJS-large.png”;
target = “AppFiles/1.png”;
}
2014-11-12 11:53:07.786 [29648:410135] File Transfer Error: Could not create path to save downloaded file: The operation couldn’t be completed. (Cocoa error 513.)

If you search Google on the error domain NSCocoaErrorDomain you find that the code 513 translates to the error NSFileWriteNoPermissionError. So I’m assuming I should be using different folders?

Also once downloaded how would I embed that image? <img src="file://AppFiles/1.png"/> ?

I’m doing my testing on IOS simulator

$cordovaFile.createDir("AppFiles", true).then(function (result) {
		        alert("Success Creating Directory");
				// Now downloda the file
		  		var source = "https://angularjs.org/img/AngularJS-large.png";
		  		var filePath = "AppFiles/1.png";
		  		$cordovaFile
		  	      .downloadFile(source, filePath, true, {})
		  	      .then(function(result) {
		  			console.log(result);
		  	      }, function(err) {
		  			console.log(err);
		  	      }, function (progress) {
		  			console.log(progress);
		  	    });
				
		    }, function (err) {
		        alert(JSON.stringify(err));
		});

Your 2nd argument of downloadFile is wrong. use NativeURL instead of the filePath.

you can read NativeURL from the success object of the CreateDir.