Crash with Stream and Zlib

15 views
Skip to first unread message

Michael Fox

unread,
Jan 31, 2016, 9:23:22 PM1/31/16
to nodejs
var drop = require('drag-and-drop-files')
var concat = require('concat-stream')
var fileReaderStream = require('filereader-stream')
var zlib = require('zlib')

drop(document.body, function(files) {
  var first = files[0]
  console.log("start gzip " + first.name);
  console.time("gzip")
  gzip = zlib.createGzip({'level':1})
  gunzip = zlib.createGunzip()
  datin = fileReaderStream(first)
  datin.pipe(gzip)
  gzip.pipe(gunzip)
  gunzip.setEncoding('utf8')
  var count = 0
  gunzip.on('data', function(chunk) { count = count + chunk.length; })
  gunzip.on('finish', function() { console.log("done, got " + count + " bytes"); console.timeEnd("gzip") })
  gunzip.on('close', function() { console.log("closed, got " + count + " bytes"); console.timeEnd("gzip") })
  gunzip.on('error',
      function(err) {
        console.log("error, got " + count + " bytes");
        console.log(err.message)
        console.log(err.stack)
        console.timeEnd("gzip")
      })
})



It's day one for me with javascript and nodejs. I have no idea. I cobbled this together, built with:

browserify -e ./ > try-build.js

and this .html file

<html>
  <body>
    Drop something on me
  </body>
  <script src='try-build.js'></script>
</html>

Crashes similarly in safari and chrome when I drop 4GB file on it. I'd appreciate any suggestions. Here's all I installed:

  npm install filereader-stream
  npm install drag-and-drop-files
  npm install concat-stream
Reply all
Reply to author
Forward
0 new messages