@ezraobiwale/upload-preview
v1.0.0
Published
Library to preview uploaded media files
Downloads
3
Readme
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