Skip to content

Read an HTML5 File object (from e.g. HTML5 drag and drops) as a stream.

License

Notifications You must be signed in to change notification settings

1N50MN14/filereader-stream

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

filereader-stream

Given a HTML5 File object (from e.g. HTML5 drag and drops), turn it into a readable stream.

NPM

If you want this for FileLists then definitely check out fileliststream.

install

Use it with npm & browserify >= 3.0

$ npm install filereader-stream

example

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
    }))
  })
})

usage

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.

About

Read an HTML5 File object (from e.g. HTML5 drag and drops) as a stream.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%