apache / cordova-plugin-file

Apache Cordova File Plugin
https://cordova.apache.org/
Apache License 2.0
740 stars 757 forks source link

File :: resolveLocalFileSystemURI problem to include a json language file #600

Closed BenLaKnet closed 8 months ago

BenLaKnet commented 8 months ago

Hi,

I tried to include js language file into my electron app, but I have an issue :

Error: exec proxy not found for :: File :: resolveLocalFileSystemURI objTraductions.js:75 FileSystem Error objTraductions.js:76 FileError

It tried to open file : "file:///www/res/languages/fr-FR.json"

I do not understand why this does not work correctly. It is running very good with Android and iOS.

Many thanks.

breautek commented 8 months ago

I'd raise the issue in the electron PR that you're using, so that it be tracked by the PR author / reviewers.

The file plugin has no actual electron implementation yet.

BenLaKnet commented 8 months ago

I found another solution. I used XMLHTTPRequest and Cordova web service on Electron.

`get_electron('res/languages/fr-FR.json', 'text');

function get_electron(url, responseType) {

return new Promise(function(resolve, reject) {

var request = new XMLHttpRequest();
request.open('GET', url);
request.responseType = responseType;

request.onload = function() {
    if (request.status == 200) {
      //resolve(request.response);
      console.log(request.response);
    } else {
      //reject(Error(request.statusText));
    }
  };

  request.onerror = function() {
    reject(Error("Network Error"));
  };

request.send();

});

}`