It seems the problem is elsewhere, not on how writing it to file, whether 
sync/async file write.

Idk what to tweak on Jester to support larger chunk processing. As for example 
on writeFromStream (not actually solving the problem tho):
    
    
    routes:
      post "/upload":
        var f: AsyncFile
        var fstream = newFutureStream[string]("routes.upload")
        try:
          f = openAsync("uploaded.file", fmWrite)
        except IOError:
          echo getCurrentExceptionMsg()
          resp Http500, "Cannot upload file"
          return
        defer: f.close
        var datastream = 
newStringStream(request.formData.getOrDefault("file").body)
        var asyncwrite = f.writeFromStream(fstream)
        while not datastream.atEnd:
          # read each of 1 MB
          let strdata = datastream.readStr(1024 * 1024)
          await fstream.write strdata
        fstream.complete
        resp Http200, "uploaded"
    
    
    Run

Reply via email to