1.0.0 • Published 4 years ago

@writetome51/get-data-url v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

getDataURL(file: Blob): Promise<string>

An async function that returns a data URL generated from file.

Example

Demonstrates usage in an Angular project:

<!--  
// example.component.html
Get a File from a file <input> and pass it to a component method:  
-->
<p>Choose file to generate data url from:</p>
<input type="file"  (change)="addToURLs($event.target.files[0])"/>
// example.component.ts:

export class ExampleComponent {
    dataURLs = [];

    async addToURLs(file) {
        let url = await getDataURL(file); // extracts url
        this.dataURLs.push(url);
    }
}

Installation

npm i  @writetome51/get-data-url

Loading

import {getDataURL} from '@writetome51/get-data-url';