Nice and good example on the upload function of the media manager!
I did it slightly different using the base64-arraybuffer npm package in my custom element and delegate (through an custom event) the upload to a controller for further handling:
upload . addEventListener ( ‘change’ , ( event ) => {
event.target.files [ 0 ]. arrayBuffer ()
. then ( bytes => base64.encode(bytes ))
. then ( base64encoded => this . dispatchEvent ( new CustomEvent ( “upload” ,{ ‘detail’ :{ ‘name’ : event.target.files [ 0 ]. name , ‘type’ : event.target.files [ 0 ]. type , ‘data’ : base64encoded }})))
});