@meniga/media
v6.1.36-alpha.0
Published
The @meniga/media package includes a component to help with file upload
Downloads
532
Readme
@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)
...
}
}
},