@webacad/observable-file-reader
v0.2.0
Published
Read file inputs with rxjs observables
Downloads
14
Maintainers
Readme
WebACAD/ObservableFileReader
Read file inputs with rxjs observables.
Dependencies
rxjs
Installation
$ npm install --save @webacad/observable-file-reader
or with yarn
$ yarn add @webacad/observable-file-reader
Usage
import {readFileAsDataURL} from '@webacad/observable-file-reader';
const file = (<HTMLInputElement>document.querySelector('#myFileInput')).files[0];
readFileAsDataURL(file).subscribe((data: string) => {
console.log('done');
console.log(data);
});
Available functions
readFileAsDataURL
: same as FileReader.readAsDataURLreadFileAsBase64
: same asreadFileAsDataURL
function but strips the base64 url prefixreadFileInChunksAsDataURL
: same asreadFileAsDataURL
function, but emitted in chunksreadFileInChunksAsBase64
: same asreadFileAsBase64
function, but emitted in chunks