Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read Text File: File Error Code 1 #2

Open
mariomka opened this issue Aug 2, 2014 · 13 comments
Open

Read Text File: File Error Code 1 #2

mariomka opened this issue Aug 2, 2014 · 13 comments

Comments

@mariomka
Copy link

mariomka commented Aug 2, 2014

Hi,

I just copy your code into a new cordova project after add android plataform and file plugin, then I get:

FileError
code 1

"1" is File not found

@cfjedimaster
Copy link
Owner

You mentioned you copied it into a new project, did you modify the JS code at all?

@mariomka
Copy link
Author

mariomka commented Aug 3, 2014

Yes, I used all of your code.

@cfjedimaster
Copy link
Owner

Hmm. Can you share a Dropbox link to the project? I'll take a look, but if the www folder is the exact same as mine, then I'm not sure what to suggest. Did you test on a device or in the Android emulator?

@mariomka
Copy link
Author

mariomka commented Aug 5, 2014

I tried in both: emulator (Android 4.4.2) and device (Nexus 5 Android 4.4.4).

Cordova version 3.5.0-0.2.6

https://dl.dropboxusercontent.com/u/18204615/testReadlFile.tar.gz

Is a strange behavior...

@cfjedimaster
Copy link
Owner

I can confirm - fails on Android. :(

@cfjedimaster
Copy link
Owner

Ok, I'm at a loss. I'm going to dig around a bit.

@cfjedimaster
Copy link
Owner

Ok, this looks to be an Android bug. :(

https://issues.apache.org/jira/browse/CB-7273

I'm sorry I never tested this (although I thought I did) - I must have assumed it was so simple that I couldn't imagine it not working.

@ghost
Copy link

ghost commented Aug 16, 2014

This bug got just a minor priority. Is there any other reliable method to read text (JSON) files from the application directory? (This is a requirement for an offline app.)

@cfjedimaster
Copy link
Owner

XHR?

@ghost
Copy link

ghost commented Aug 16, 2014

XHR for local file system? That's new to me.

What I'm looking for is loading JSON files which are installed with the app on the device, in a directory such as www/json/ .

@ghost
Copy link

ghost commented Aug 16, 2014

BTW, a reliable way to do that was using RequireJS, however, since cordova version 3.5.0 there seem to be again conflicts when using booth API's together.

@cfjedimaster
Copy link
Owner

By XHR I just mean Ajax. If you look at the source code in the demo, I
think I even mention that.

On Fri, Aug 15, 2014 at 11:15 PM, bardu notifications@github.com wrote:

BTW, a reliable way to do that was using RequireJS, however, since cordova
version 3.5.0 there seem to be again conflicts when using booth API's
together.


Reply to this email directly or view it on GitHub
#2 (comment)
.

Raymond Camden, Web Developer for Adobe

Email : raymondcamden@gmail.com
Blog : www.raymondcamden.com
Twitter: raymondcamden

@mamrehn
Copy link

mamrehn commented Oct 7, 2014

If anyone is still searching, this is a working solution for files in www/ (or www/videos/ respectively).

var myFilename = "testvid.webm";
var myUrl = cordova.file.applicationDirectory + "www/videos/" + myFilename;
var fileTransfer = new FileTransfer();
var filePath = cordova.file.dataDirectory + myFilename;
var allowFromAll = false;

fileTransfer.download(encodeURI(myUrl), filePath, (function(entry) {
  /*
  res = "download complete:\n"
  res += "fullPath: " + entry.fullPath + "\n"
  res += "localURL: " + entry.localURL + "\n"
  alert(res += "nativeURL: " + entry.nativeURL + "\n")
   */
  var vid = document.getElementById("someID");
  vid.src = entry.nativeURL;
  angular.element(v).loop = true;
}), (function(error) {
  alert("Video download error: source " + error.source);
  alert("Video download error: target " + error.target);
}), allowFromAll, {
  headers: {
    Authorization: "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
  }
});

(try to set allowFromAll to true if it does not work for you.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants