Avatar for beweOnline


Member since Aug 2022 • Last active May 2023
  • 1 conversations

Espruino's just so cool!

Most recent activity

  • in ESP8266
    Avatar for beweOnline

    Thanks for your reply! While I can slice up the file into chunks and write a GET response using the node.js drain event as explained in the tutorial mentioned above, I was hoping someone could shed light on the whole matter. I'm curious as to why E.pipe() is available when E.openFile() is not! What's the use case here?

    Anyways, I post my WIP here, in case somebody's wondering. This goes into the routing callback function you'd supply to the createServer() method:

    var storage = require("Storage");
    var file = storage.read("xyz.html");
    res.writeHead(200, {'Content-Type': 'text/html'});
    // write response in packets
    var packet = 4096;
    var chunks = Math.ceil(file.length/packet);
    var n = 1;
    res.on('drain',function() {
         else if(n>=2 && n<=chunks){
  • in ESP8266
    Avatar for beweOnline

    Dear all!
    Reading a file with require("Storage").read() but running out of mem with larger files, like serving a ~20kb html file. So I want to stream instead as suggested here. However, if the NodeMCU hasn't got E.openFile(), how then do you open a file for streaming such that I might use E.pipe()?
    Scratching my head over this one. Any help much appreaciated!