How do read data from the app loader

Posted on
  • I tried to follow the tutorial here: http://www.espruino.com/Bangle.js+Storag­e but get no content for any file.

    I'm trying to read a json file from the app loader, but I always get 0 bytes. Maybe someone has a clue what I'm doing wrong, steps to reproduce:

    1. Running a local server with npm start
    2. Add a interface.html to any random app by adding
      "interface": "interface.html"
      to metadata.json
    3. Create interface.html with content from http://www.espruino.com/Bangle.js+Storag­e
    4. Replace 'gpspoilog.csv' with 'setting.json' because that file surely exists. But with the download button I get no data. Output in the console:

    readStorageFile "setting.json"
    comms.js:431 readTextBlock read started...
    comms.js:417 size is 0


    1 Attachment

  • Strange, I can read accellog.0.csv generated with accellog, but not setting.json

  • Replace 'gpspoilog.csv' with 'setting.json' because that file surely exists. But with the download button I get no data.

    Ahh - this is your issue I think. There are two different types of file on Bangle.js:

    • Normal files of a fixed length created with require("Storage").write
    • "StorageFile" files created with require("Storage").open which can be appended to

    You're trying to load the first type (setting.json) using code meant for the second type (gpspoilog.csv).

    Try using Util.readStorage("setting.json") instead and it'll probably be fine (the code normally used Util.readStorageFile)

  • Confirmed, that works, thank you. Would be nice to have this in the tutorial under http://www.espruino.com/Bangle.js+Storag­e

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How do read data from the app loader

Posted by Avatar for user140377 @user140377

Actions