Given a HTML5 File object (from e.g. HTML5 drag and drops), turn it into a readable stream.
If you want this for FileLists then definitely check out fileliststream.
Use it with npm & browserify >= 3.0
$ npm install filereader-stream
var drop = require('drag-and-drop-files');
var concat = require('concat-stream');
var createReadStream = require('filereader-stream');
test('should read file when one is dropped', function(t) {
drop(document.body, function(files) {
var first = files[0]
createReadStream(first).pipe(concat(function(contents) {
// contents is the contents of the entire file
}))
})
})
var createReadStream = require('filereader-stream'. [options]);
options
is optional and can specify output
. Possible values are:
arraybuffer
[default]binary
dataurl
text
You can also specify chunkSize
, default is 8128
. This is how many bytes will be read and written at a time to the stream you get back for each file.