My following code for uploading an image to firebase storage is working properly.
But I want to reduce the file size of "file1 (The image)" to 100px*100px. And upload it to firebase storage.
function uploadImage() {
const ref = firebase.storage().ref();
const file1 = document.querySelector("#photo").files[0];
const metadata = {
contentType: file1.type
};
const task = ref.child(mydata.uid).put(file1, metadata);
task
.then(snapshot => snapshot.ref.getDownloadURL())
.then(url => {
db.collection('user').doc(mydata.docid).update({
profilepic : url,
});
const image = document.querySelector("#image")
image.src = url;
alert("uploaded")
})
.catch(console.error);
}
Please provide the full code for uploading a resized image to the firebase storage.