@meniga/media

6.1.8 • Public • Published

@meniga/media

The @meniga/media package includes a component to help with file upload

Usage


import { FileUploader } from '@meniga/media'

<FileUploader 
	ref={ t => this.fileUploader = t } 
	primary 
	light 
	onUpload={ this.handleUpload } 
	uploadFileText={ uploadButtonText } />

The onUpload callback will return the file you just uploaded, and you can use FileReader to read it.

Example:

this.handleUpload = (file, type) => {
	if(file) {
		const read = new FileReader();
		read.readAsText(file);

		read.onloadend = function(){
			const data = read.result || null
			const jsonData = JSON.parse(data)

			...
		}
	}
},

Readme

Keywords

none

Package Sidebar

Install

npm i @meniga/media

Weekly Downloads

62

Version

6.1.8

License

MIT

Unpacked Size

11.5 kB

Total Files

6

Last publish

Collaborators

  • meniga-npm
  • petermeniga
  • tinna