https://github.com/web-acad/observable-file-reader
Read file inputs with rxjs observables
https://github.com/web-acad/observable-file-reader
Last synced: 8 months ago
JSON representation
Read file inputs with rxjs observables
- Host: GitHub
- URL: https://github.com/web-acad/observable-file-reader
- Owner: Web-ACAD
- License: mit
- Created: 2018-05-19T20:35:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-24T14:06:36.000Z (almost 8 years ago)
- Last Synced: 2025-09-15T17:53:40.780Z (9 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/@webacad/observable-file-reader)
[](https://travis-ci.org/Web-ACAD/observable-file-reader)
# WebACAD/ObservableFileReader
Read file inputs with rxjs observables.
## Dependencies
* `rxjs`
## Installation
```bash
$ npm install --save @webacad/observable-file-reader
```
or with yarn
```bash
$ yarn add @webacad/observable-file-reader
```
## Usage
```typescript
import {readFileAsDataURL} from '@webacad/observable-file-reader';
const file = (document.querySelector('#myFileInput')).files[0];
readFileAsDataURL(file).subscribe((data: string) => {
console.log('done');
console.log(data);
});
```
## Available functions
* `readFileAsDataURL`: same as [FileReader.readAsDataURL](https://developer.mozilla.org/en-US/docs/Web/API/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