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

blob url #41

Closed
mshqlaih opened this issue Apr 27, 2021 · 6 comments
Closed

blob url #41

mshqlaih opened this issue Apr 27, 2021 · 6 comments

Comments

@mshqlaih
Copy link

hi
after i upload my image the src of image is like this :
blob:http://academicprogs.iugaza.edu/e6475d62-18dc-419d-adec-7719c10de1d3
i can get this src, but how can i save it to then server or getbase64 of this src.

any help please.

thanks
maher

@mshqlaih
Copy link
Author

@fengyuanchen any help please.

@fengyuanchen
Copy link
Owner

This project is a photo editing application based on Cropper.js, so I will suggest using the Cropper.js directly.

@mshqlaih
Copy link
Author

mshqlaih commented May 1, 2021

but this project help alot and it is very helpful , and I want only an answer for above question if you can help me.

@fengyuanchen
Copy link
Owner

You can load the URL by XMLHttpRequest with the responseType set to "blob".

@mshqlaih
Copy link
Author

mshqlaih commented May 3, 2021

@fengyuanchen many thanks for your help.
i used this code to solve my problem:
var iframe = document.getElementById("ifphoto");
var base64 = (iframe.contentWindow.document.getElementsByTagName("a")[0]).toString();
apex.message.clearErrors();
if (base64.toString().indexOf('http') > 0 ) {

const createImageFromBase64 = function(event) {
//const img = document.createElement('img');
console.log(this.result);
base64 = this.result;
base64 = base64.toString().replace("data:", "").replace(/^.+,/, "");
apex.item('P27_BASE64').setValue(base64);
}

const onLoadReadBlobAsBase64 = function(event) {
const blob = this.response;
const reader = new FileReader();
reader.onloadend = createImageFromBase64;
reader.readAsDataURL(blob);
}

var xhr = new XMLHttpRequest();
xhr.open("GET",base64);
xhr.responseType = "blob";
xhr.onload = onLoadReadBlobAsBase64;
xhr.send();
}
else {
base64 = base64.toString().replace("data:", "").replace(/^.+,/, "");
apex.item('P27_BASE64').setValue(base64);
}

@mshqlaih
Copy link
Author

mshqlaih commented May 3, 2021

@fengyuanchen may I ask another question :
How can I show image directly on photo-editor without upload it , and then make any process to it.

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