How can i upload an image from js to minio?
I tried this code.
minioClient.putObject('image-test', this.state.Img.name, this.state.result, 'image/png', function(err, etag) {
if (err) return console.log(err)
console.log('File uploaded successfully.')
});
i set content type as ‘image/png’ but on minio server i still got ‘binary/octet-stream’
enter image description here
and this is how I get file
handleImageChange(e) {
e.preventDefault();
var reader = new FileReader();
var file = e.target.files[0];
reader.onloadend = () => {
console.log('file name—',file);
console.log('file result—',reader.result);
this.setState({
Img: file,
result: reader.result
});
}
reader.readAsDataURL(file)
}
the input component looks like
<Button
variant="contained"
component="label"
fullWidth
>
Upload File
<input
type="file"
hidden
onChange={e => this.handleImageChange(e)}
/>
</Button>