fileliststream
v0.0.3
Published
Convert a DOM FileList to a FileListStream. Uses a FileReader to read the data of each file as a stream.
Downloads
13
Readme
fileliststream
Given a FileList, turn it into a FileListStream.
example
const FileListStream = require('fileliststream');
const body = document.body;
// make it so console can be piped to.
console.write = console.log;
function noop(name) {
event.preventDefault();
event.stopPropagation();
return false;
};
['dragenter',
'dragleave',
'dragexit',
'dragover'
].forEach(function (eventType) {
body.addEventListener(eventType, noop);
});
body.addEventListener('drop', function (event) {
event.stopPropagation();
event.preventDefault();
const fileList = FileListStream(event.dataTransfer.files);
fileList.files.map(function(file) {
file.pipe(console);
});
return false;
});
usage
FileListStream(fileList, [options])
options
currently has one possible parameter, output
. Possible values are:
binary
dataurl
arraybuffer
text