I have reactjs app and some images to show. Now I try to optimise my images. So I tried to resize and change the image to Webp format using firebase's Resize Image extension. So I got the images with name, example test_album_40x40.webp, test_album_300x300.webp. My question is that how can I get that url. When I upload image.jpeg, I got the following url return from firestore.
test_album.jpeg (original url that return from firestore when it is upload and store it in db)
test_album_40x40.webp
test_album_300x300.webp
Update Event to firestore and save to db
const handleSave = async (data) => {
const file = data.album_cover;
const storageRef = ref(storage, "images/albums/" + file.name);
const uploadTask = uploadBytesResumable(storageRef,file);
uploadTask.on(
"state_changed",
(snapshot) => {
var progress = Math.round(snapshot.bytesTransferred / snapshot.totalBytes) * 100;
setUploadProgress({ progress });
},
(error) => {
throw error;
},
() => {
getDownloadURL(uploadTask.snapshot.ref).then((url) => {
data.album_cover = url;
add_albumByArtist({
variables:addVariable(data, auth),
refetchQueries: [getAlbums]
});
}
);
}
);
navigate(-1);
};