Slide 7
Slide 7 text
Implementation
Use to upload a file and write an onChange
handler.
const handleChange = (event: React.ChangeEvent) => {
const file = event.target.files![0];
// ...
const contentType = file.type;
const id = String(Date.now());
const storageRef = ref(storage, `videos/${auth.id}/${id}.${extension}`);
const metadata = {
contentType,
};
const uploadTask = uploadBytesResumable(storageRef, file, metadata);
uploadTask.on("state_changed", onProgress, onError, onComplete);
};