• Project is to support uploading of files and save on SD.
    It is tested on ESP32, I don't have hardware to compare with espruino board.
    If this is a ESP32 problem only, please move it to ESP32 forum.
    Doing the job with piping does not save full upload, some data at the end is missing

    function postUpload(req,res){
        var a = url.parse(req.url,true);  //there is a parameter given for location of new file on SD
        var f = E.openFile(a.query.pathname,"w");
        req.pipe(f,{chunkSize:32, end:false,
          complete:function(){
              f.close();
              res.end();
          }
        });
      }
    

    Doing same without piping works fine

    function postUpload(req,res){
        var a = url.parse(req.url,true);
        var f = E.openFile(a.query.pathname,"w");
        req.on("data",function(data){f.write(dat­a);});
        req.on("close",function(){
          f.close();
          res.end();
        });
      }
    
About

Avatar for JumJum @JumJum started