Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload images and attach as base64 #861

Open
afaraha8403 opened this issue Aug 5, 2019 · 2 comments
Open

Upload images and attach as base64 #861

afaraha8403 opened this issue Aug 5, 2019 · 2 comments

Comments

@afaraha8403
Copy link

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
Copy link
Author

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

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

@prnvsharma68
Copy link

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);
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants