I am having a bit issue with trying to convert my image to blob
file = "assets/imgs/profile.png"
//this is the image to be changed to a blob
let reader = new FileReader()
reader.readAsArrayBuffer(file);
reader.onloadend = (evt: any) => {
let imgBlob = new Blob([evt.target.result], { type: 'image/jpeg' });
}
I am trying to upload the image to a REST API written in PHP laravel and its expecting the image in blob
(Sorry for super late reply from nowhere) but I can’t find any sign of non template code in your project that is helping me at all. Can you point out what file or code snippets I should look at to figure out what you did?
var file = 'assets/assets/imgs/profile.png';
fetch(file)
.then (res => res.blob()) // Gets the response and returns it as a blob
.then (blob => {
firebase.storage().ref().child('/userProfile/' + this.currentUser.uid + '/profilePicture.png')
.put(blob).then( savedPicture => {
console.log('Uploaded img file!');
// now you can save your URL for output in HTML
this.userProfileRef.update({"profilePicture": savedPicture.downloadURL})
}); /*
});