WP8 / Cordova file system - does anyone know the correct code?

There is a serious lack of documentation on how to use the plugin for Cordova files with the WP8 platform.

I have an application on Android, fireOS and iOS, all with a plugin to view the contents of the directory, download, save and open the generated files from my web service, which use the following code:

function listDir() { //console.log('listDir'); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); function gotFS(fileSystem) { //console.log('gotFS. filesystem.root = ' + fileSystem.root.value); fileSystem.root.getDirectory("MyFolder", { create: true, exclusive: false }, gotDir); } function gotDir(dirEntry) { //console.log('gotDir'); // Get a directory reader var directoryReader = dirEntry.createReader(); // Get a list of all the entries in the directory directoryReader.readEntries(success, fail); } function success(entries) { var i = 0, sb = ''; sb += '<ul data-role="listview" data-inset="true" id="pdfFiles">'; if (entries.length > 0) { for (i = 0; i < entries.length; i++) { sb += '<li><a href="#" data-src="' + entries[i].toURL() + '"><img src="images/icons/icon_pdf.png" class="ui-li-icon" width="16px" height="16px" alt="PDF Icon" />'; sb += entries[i].name; //sb += '<br />'; //sb += entries[i].fullPath; sb += '</a></li>'; } } else { sb += '<li><p>You do not have any saved reports</p></li>'; } sb += '</ul>'; $('#pdfReports-entries').html(sb); $('ul#pdfFiles').listview().listview('refresh'); //open the pdf file using the fileOpener plugin $('ul#pdfFiles li a').on('click', function () { $this = $(this); window.plugins.fileOpener.open($this.attr('data-src')); }); } function fail(error) { logError("Failed to list directory contents: " + error.code); sb += '<ul data-role="listview" data-inset="true" id="pdfFiles">'; sb += '<li><p>You do not have any saved reports</p></li>'; sb += '</ul>'; $('#pdfReports-entries').html(sb); $('ul#pdfFiles').listview().listview('refresh'); } 

}

WP8 generates the following error in the gotFS function:

 A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.ni.dll 

Then I tried this Github code, which still could not create or read any directories, but did not throw an IsolStorageException.

I have asked Google many times, but it cannot give a consistent answer.

Does anyone know how to use the plugin for files with WP8?

+5
source share
1 answer

In connection with my comment above, but wanted a place to put the code ...

I myself have not used the WP8 application, only iOS and Android, but maybe the application does not have the correct permissions?

They will go to your Properties/WPAppManifest.xml and will look like this:

 <Capabilities> <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" /> <Capability Name="ID_CAP_IDENTITY_DEVICE" /> <Capability Name="ID_CAP_IDENTITY_USER" /> </Capabilities> 

And a list of available feature identifiers is listed here on MSDN . Although the only one I see related to file storage is ID_CAP_REMOVABLE_STORAGE , maybe this is not a problem ... I thought the link above might be useful.

+2
source

Source: https://habr.com/ru/post/1203827/


All Articles