JSPM

filereader-stream

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3999
  • Score
    100M100P100Q126560F
  • License BSD 2-Clause

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

Package Exports

  • filereader-stream

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (filereader-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.

run the tests

npm install
npm test

then open your browser to the address provided, open your JS console, and drag and drop files onto the page until the test suite passes/fails