Read W3C Blob & File objects as a Node stream. Very useful with "browserify" and "primus" with "ejson" using pipe()
Last updated 5 years ago by joris-van-der-wel .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install readable-blob-stream 
SYNC missed versions from official npm registry.


Read W3C Blob & File objects as a Node stream. Very useful with "browserify" and "primus" with "ejson" using pipe().


If you are already generating a bundle using browserify (or something similar), you can use it directly:

npm install readable-blob-stream --save
var ReadableBlobStream = require('readable-blob-stream');

Or, you can generate a standalone javascript file by cloning or downloading this repo and typing:

npm install
npm run bundle

Look in the build directory to find the generated file. This is a UMD module. Which means you can either require() it using browserify, load it using AMD, or access it as the global window.ReadableBlobStream


<!DOCTYPE html>
<script src="readable-blob-stream.js"></script>
window.addEventListener('DOMContentLoaded', function()
    var myfile = document.getElementById('myfile');

    myfile.addEventListener('change', function()
        var file = myfile.files[0];
        if (!file) { return; }

        var stream = new ReadableBlobStream(file);
        // or:
        //var stream = new ReadableBlobStream(file, {highWaterMark : 128, encoding: 'utf8'});

        stream.on('error', function(err)
            console.log('error while reading your file:', err);

        stream.on('end', function()
            console.log('there will be no more data.');

        stream.on('data', function(data)
            // if you do not set an encoding,
            // "data" is both a Buffer and an Uint8Array
            console.log('got %d amount of data: ', data.length, data);

        // If you are using primus you can simply use:
        //     stream.pipe(spark);
        // instead of using the 'data' listener
<input type="file" id="myfile">

Current Tags

  • 1.1.0                                ...           latest (5 years ago)

3 Versions

  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.0.0                                ...           6 years ago
Maintainers (1)
Today 0
This Week 4
This Month 4
Last Day 0
Last Week 0
Last Month 2
Dependencies (1)
Dev Dependencies (1)

Copyright 2014 - 2016 © |