Hi How can I upload files using my own function which is below. and use return url inside rich text editor Hope you got me Thanks
const handleUpload = async (e) => {
try {
// console.log("start of upload 2", e)
// async magic goes here...
//let promise = $.Deferred();
showLoader(true)
const uploadTask = dynamicstorage('link').ref(`/images/${e.name}`).put(e)
// const urlLink = (await uploadTask).ref.getDownloadURL();
//hideLoader();
uploadTask.on(
"state_changed",
(snapshot) => {
//takes a snap shot of the process as it is happening
const progress = Math.round((snapshot.bytesTransferred / snapshot.totalBytes) * 100)
//setProgress(progress)
},
(err) => {
//catches the errors
console.log("Hi=", err)
},
() => {
// gets the functions from storage refences the image storage in firebase by the children
// gets the download url then sets the image from firebase as the value for the imgUrl key:
dynamicstorage('link')
.ref("images")
.child(e.name)
.getDownloadURL()
.then((fireBaseUrl) => {
//handleUpdateCompanyInfo(fireBaseUrl,key);
// console.log(fireBaseUrl)
//setCImage(fireBaseUrl)
setPath(()=>fireBaseUrl)
hideLoader()
})
}
)
} catch (error) {
console.log("Hi==", error)
}
}