editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Upload images and attach as base64

Open afaraha8403 opened this issue 7 years ago • 2 comments

Hey Guys I have a requirement to upload the images as base64. So instead of passing the images to an end point url they will be embedded as base64. Can someone pass me in the right direction

Thanks

afaraha8403 avatar Aug 05 '19 15:08 afaraha8403

For anyone else that's looking you can use this method on upload

https://github.com/editor-js/image#server-format

afaraha8403 avatar Aug 19 '19 00:08 afaraha8403

you can try

uploadByFile(file){ return _getBase64(file, function(e) {}).then((data)=>{ return { success: 1, file: { url: data } } }) }

declare function function _getBase64(file, onLoadCallback) { return new Promise(function(resolve, reject) { var reader = new FileReader(); reader.onload = function() { return resolve(reader.result ); }; reader.onerror = reject; reader.readAsDataURL(file); }); }

prnvsharma68 avatar Jul 10 '20 18:07 prnvsharma68