Name: pull-file-reader
Owner: TABLEFLIP
Description: Read an HTML5 File object (from e.g. HTML5 drag and drops) as a pull stream source.
Created: 2017-02-09 12:42:43.0
Updated: 2018-04-10 15:01:44.0
Pushed: 2017-05-31 09:07:14.0
Homepage: null
Size: 6
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Given an HTML5 File object (from e.g. HTML5 drag and drops), turn it into a pull stream source.
Heavily based on filereader-stream by @maxogden.
Use it with npm & browserify
install pull-file-reader
drop = require('drag-and-drop-files')
pull = require('pull-stream')
fileReader = require('pull-file-reader')
(document.body, function (files) {
r first = files[0]
ll(
fileReader(first),
pull.collect(function (err, buffs) {
var contents = Buffer.concat(buffs)
// contents is the contents of the entire file
})
fileReader = require('pull-file-reader')
source = fileReader(file, [options])
fileReader
is a pull stream source.
options
:
chunkSize
- default 1024 * 1024
(1MB) - How many bytes will be read at a timeoffset
- default 0
- Where in the file to start readinginstall
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
A (?°?°???TABLEFLIP side project.