Rx.DOM.fromReader(file, [progressObserver])
Ⓢ
The FileReader object lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read as an observable sequence.
file
(File | Blob
): The file to read.[progressObserver]
(Rx.Observer
): An optionalObserver
to watch for progress events.
(Object): An object which has the following functions:
asArrayBuffer()
- (Rx.Observable
): This method is used to read the file as an ArrayBuffer as an Observable stream.asBinaryString()
- (Rx.Observable
): This method is used to read the file as a binary data string as an Observable stream.asDataURL()
- (Rx.Observable
): This method is used to read the file as a URL of the file's data as an Observable stream.asText(encoding)
- (Rx.Observable
): This method is used to read the file as a string as an Observable stream.
Read the contents of the file picker only if plain files:
Rx.DOM.change(filesInput)
.flatMap(function (event) {
return Rx.Observable.from(event.target.files);
})
.filter(function (file) {
return file.type.match('plain');
})
.flatMap(function (file) {
return Rx.DOM.fromReader(file).asText();
})
.subscribe(function (contents) {
console.log(contents);
});
File:
Dist:
Prerequisites:
NPM Packages:
NuGet Packages:
Unit Tests: