@meniga/media

6.1.9 • 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)

			...
		}
	}
},

Dependencies (3)

Dev Dependencies (5)

Package Sidebar

Install

npm i @meniga/media

Weekly Downloads

118

Version

6.1.9

License

MIT

Unpacked Size

68.3 kB

Total Files

3

Last publish

Collaborators

  • meniga-npm
  • petermeniga
  • tinna