Miss any of our Open RFC calls?Watch the recordings here! »

@webacad/observable-file-reader

0.2.0 • Public • Published

NPM version Build Status

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.readAsDataURL
  • readFileAsBase64: same as readFileAsDataURL function but strips the base64 url prefix
  • readFileInChunksAsDataURL: same as readFileAsDataURL function, but emitted in chunks
  • readFileInChunksAsBase64: same as readFileAsBase64 function, but emitted in chunks

Install

npm i @webacad/observable-file-reader

DownloadsWeekly Downloads

66

Version

0.2.0

License

MIT

Unpacked Size

8.31 kB

Total Files

8

Last publish

Collaborators

  • avatar