aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/UploadForm.jsx
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-26 21:35:30 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-26 21:35:30 +0530
commite9d14a0a516217da02e1ef8a6e1dc78e46116b18 (patch)
treea38d09f714856f11724d10acb77692704278a109 /src/components/UploadForm.jsx
parent55aed6d7c2df0daedbdabea0d1727acb1815ce2b (diff)
downloadadmin-panel-e9d14a0a516217da02e1ef8a6e1dc78e46116b18.tar.gz
admin-panel-e9d14a0a516217da02e1ef8a6e1dc78e46116b18.tar.bz2
admin-panel-e9d14a0a516217da02e1ef8a6e1dc78e46116b18.zip
fetching the content from firebase
Diffstat (limited to 'src/components/UploadForm.jsx')
-rw-r--r--src/components/UploadForm.jsx11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/components/UploadForm.jsx b/src/components/UploadForm.jsx
index 9bb16e7..531feda 100644
--- a/src/components/UploadForm.jsx
+++ b/src/components/UploadForm.jsx
@@ -4,7 +4,6 @@ import { storage } from '../firebase';
const UploadForm = ({ onUploadComplete }) => {
const [file, setFile] = useState(null);
- const [progress, setProgress] = useState(0);
const handleFileChange = (e) => {
setFile(e.target.files[0]);
@@ -16,16 +15,15 @@ const UploadForm = ({ onUploadComplete }) => {
const storageRef = ref(storage, `ads/${file.name}`);
const uploadTask = uploadBytesResumable(storageRef, file);
- uploadTask.on(
- 'state_changed',
+ uploadTask.on('state_changed',
(snapshot) => {
- const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
- setProgress(progress);
+ // Observe state change events such as progress, pause, and resume
},
(error) => {
- console.error('Upload failed', error);
+ console.error('Upload error:', error);
},
() => {
+ // Handle successful uploads on complete
getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
onUploadComplete(downloadURL);
});
@@ -37,7 +35,6 @@ const UploadForm = ({ onUploadComplete }) => {
<div>
<input type="file" onChange={handleFileChange} />
<button onClick={handleUpload}>Upload</button>
- <div>Upload Progress: {progress}%</div>
</div>
);
};