1.0.0 • Published 3 years ago

@ezraobiwale/upload-preview v1.0.0

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

Upload Preview

Creates a url that can be provided to <image src="..." /> from <input type="file">.

Install

yarn add @ezraobiwale/upload-preview

Usage

Preview a file input

<img id="file-preview" src="#" alt>

<input id="file" type="file">
import preview from '@ezraobiwale/upload-preview'

preview('#file', '#file-preview')

// or do something else with the result

preview('#file', ({ url, raw }, index, error) => {
   // do something with url or raw
})

Reading file manually

import { readFile } from '@ezraobiwale/upload-preview'

const file = File // a file object gotten from wherever

const { url, raw } = await readFile(file)
// do something with url or raw
1.0.0

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago