I tried so many method to download image from firebase but download URL is nor working as what i expected, Its open the image in new tab.
The firebase function:
export async function addMedia(location: "initial" | "prep" | "merge" | "sribe" | "other", file: string) {
let fileName = uuidv4();
const storageRef = ref(storage, `/${location}/${fileName}`);
let downloadLink = "";
await uploadString(storageRef, file, "data_url").then(async (snapshot) => {
await getDownloadURL(snapshot.ref).then((link: any) => {
downloadLink = link;
})
})
return downloadLink;
I'm using file-saver dependencies for my download purpose its working fine.
File download function:
const downloadImage = (url: any, name: any) => {
console.log(url, name, "image details");
FileSaver.saveAs(url,name);
}
The fire base URL im getting from firebase function:
When i press download i get below result :