DEV Community

Discussion on: CKEditor Image upload with Firebase and React

Collapse
sands45 profile image
Sands

Here is the code with Firebase 9
class MyUploadAdapter {
constructor(loader) {
this.loader = loader;
}
// Starts the upload process.
upload() {
return this.loader.file.then(
(file) =>
new Promise((resolve, reject) => {
let storage = getStorage();
uploadBytes(
ref(storage, /${"Dial & Dine"}/${new Date().getTime()}),
file
)
.then((snapshot) => {
return getDownloadURL(snapshot.ref);
})
.then((downloadURL) => {
resolve({
default: downloadURL,
});
}).catch((error)=>{
reject(error.message);
})
})
);
}
}