It's a shame that useful videos like this one don't get more likes. Thank you very much for this. Edit: I just saw that you have a playlist on react firebase. Please continue what you're doing, we need more people like you.
This is a great video on storing images in firebase. I've been running around the internet for the past day trying to figure out how to get it done, but it seemed like all the content was out of date. This tutorial saved me a lot of trouble. Thanks again.
@anona lol Yeah I'm definitely having a lot of trouble getting things working - I haven't made much progress since this comment as it's hard to find good resources. Net Ninja has a good intro series on his channel, but it doesn't cover enough. His Udemy course has been really good, but it's also outdated. Would love to know if you find any good resources!
you saved my life! the documentation is not clear unlike your video i have a question> what is the difference between setDoc() and the method you have used in this video
Hey thanks for your feedback!! Really appreciate it. Coming to your question setDoc is a method used in firebase firestore (not firebase storage) to add data.
Awesome! Thank you! Man, great tutorial. I was having such a headache with v9 and combing through Firebase docs. Thank you for simplifying this. Liked and subscribed
Typically you need to have a Backend written where you should use google cloud storage, as using it directly in your frontend will expose you secret api keys.
Since there are 2 ref plugins, it gives the following error. Can you help please? import { set, ref, } from "firebase/database"; import { getDownloadURL, uploadBytesResumable, ref,} from 'firebase/storage'; Terminal : Parsing error: Identifier 'ref' has already been declared.
You can try alias named import. Something like this import { set, ref as dbRef } from "firebase/database"; import { getDownloadURL, uploadBytesResumable, ref as storageRef} from 'firebase/storage';
Very useful, thank you. I followed your video and got my test-app working in minutes & was able to use that info for my intended project! May I suggest you look into using a .env file to protect your firebase credentials from showing up your public github repo? I'm hesitant to leave API keys on public repos - but that's your preference.
Yes surely you can use .env for firebase config. Just for the demonstration I have kept it public and since I have already deleted the project from my firebase console so any ways the api key won’t be usable. But thanks for observation. Really appreciated
I have spent up to two days trying to figure this out. T han you so much for the video. It was amazing. I do need advice, the image is being saved in the storage however it isn't displaying in the storage, its there but i xan't see the actual image. I know it has to do with the file format from expo image picker. I need to convert it to bytes, aby ideas on how to do this? Thank you
Hey, this video helps me a lot, but will you please tell me how to display that picture on the web page. Like a person login from the firestore collection and authentication and how do I display his picture as a profile pic.
You can store the download url of the picture in the users collection and then use it when user logs in. There's another way if you just want to store the img for profile picture only. You can do this by simply setting the display image for your authenticated user by updating the user profile. Follow this for more - firebase.google.com/docs/auth/web/manage-users#update_a_users_profile
Hey There, Thanks for this solution. But please hear me out, I want to post a picture along with a caption text to firestore. so, the imageURL will be sent to storage, and caption text to firestore. but i am getting errors in doing so. can you please provide some implementation to this
You can store the image to firebase storage then get the download url. Then in the Firestore you need to store the url caption and other details you want. Then everything can be fetched from the Firestore in one go. Apart from this if you just want to have a caption to your image you can just update the meta data of the image with your custom metadata. Implementation can be found here firebase.google.com/docs/storage/web/file-metadata
Hey man great video. I need help. I'm going to use firebase storage to upload files. But I also want to store that url into mongodb, instead of just console.log(url). How can I do that? Sorry I'm a beginner
Once you get the download Url for the uploaded file you can make a request to your backend with the URL as a payload and then in your backend you can store the same in the MongoDb. Note- Connecting your MongoDB directly to your frontend can be a security issues as you will expose your db api keys and credentials to the public
@@FullstackSimplified Thanks for the reply. Another Question bro. What if I want to upload multiple files. Like Select 1 file then upload like we did here. Staying on the same page. Select another file and upload. Select 3rd file then upload. If that makes sense
How can we fetch this image and use it along with some textual data from the database , like i want to create a card with title , image and description, so the image come from the storage but how can I use title and description which comes for the firebase store and use all this with map function to map all the cards and display them
Hi. You can store the image download url in the database along with other data you have and then you can simply use the url from the response in img src
10:34 I write console.log(url) and it gives me a working url in Storage, but when doesnt work when i do setImage(url), it pass a empty string, do you know why or how can i fix that?
hi, i follow your instruction and got this error: "Uncaught ReferenceError: ref is not defined" at the line const storageRef = ref(storage, `/images/${image.name}`); what is wrong?
Well you can do so by transcoding your video into smaller chunks and uploading it to firebase storage. Then you can store the chunk detials in firestore and download chunks as the video progress. But this would be really expensive so i would suggest to use some 3rd party solutions like Vimeo or ziggeo. You can also use webrtc of you have your own backend
@@FullstackSimplified I checked it out however, I still cant get to find the way to retreive the url variable outside of the function. I want to be able to add the url to a document in the firestore so I can download it into the UI latter
@@FullstackSimplified but please make it work. I see RUclipsrs on here that do fire base tutorials and it’s 20222 but for the tutorial they are using fire base 2018
You can select 2 images from the file picker by making it accept multiple images. Then you can loop over the selected images and call the upload function for all the selected images. Or if you want to select one photo at a time then you can open the file picker twice and upload the selected photos one by one using the same upload function
@@FullstackSimplified Actually I was planning to create separate file picker for both images like profileImage and CoverImage. So will I have to create separate handleImageChange Functions ? Or it can be done in one function itself?
Hi i am getting error like this Permission denied. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources.
Thank you so much for the video. Can someone tell me how to upload an image and an audio together through a single form along with a the name of the song (user specified). Something like an online music player. I've been stuck here for days pls helpp.
You have to upload them separately. Then you can store the download URL for both the files in Firestore or realtime database. Something like { name : "Song name", albumArt : , audio : }
@@FullstackSimplified thank youuu. I did just that and it worked but I've to create some sort of a pause between uploading the file and adding the doc to firestorm. Currently my adddoc and uploading runs simultaneously so an empty string gets uploaded to firestore since uploading takes some time
Well in firebase you can only upload 1 file at a time. If you want to upload multiple files you will have to loop over your files one by one and upload them using the loop. You can also use Promise.all to resolve the all the promises and then get an array of response
What happens if two files have the same name? Why isn't that really important thing addressed here? One way is to use uid of a currently authenticated user which we can get from auth.currentUser.uid. If your app has multiple files to upload such as cover letter, resume etc they should probably point to different folders. If the user reuploads any of them it will rewrite the previous file in the storage and not fill your storage with duplicates.
Authentication was not covered in this video. It was more about the basics of file uploading. For the file name you can use any thing which suits your application architecture to avoid duplicates or file over riding
It's a shame that useful videos like this one don't get more likes. Thank you very much for this.
Edit: I just saw that you have a playlist on react firebase. Please continue what you're doing, we need more people like you.
Thanks for your support. Really appreciate it
Truly, this video is so nice if i had a way to support, I will not waste a thousandth of a second
Cleared all the confusion in just 10 mins tutorial.
You are a champ bro.
You truly saved my day.
Thank you sooo sooo much bro.
Thanks alot for watching. Really means alot 🔥🔥
This is a great video on storing images in firebase. I've been running around the internet for the past day trying to figure out how to get it done, but it seemed like all the content was out of date. This tutorial saved me a lot of trouble. Thanks again.
Really appreciate your feedback. Thanks for watching
Followed a lot of tutorials but this one finally worked! Thanks a lot!!
Thanks for watching. Really appreciate
Happy diwali sir.... Diwali pe bhi video pe kaam... Dedication level 🔥🔥🔥
Thanks alot. And happy diwali 🎇
I was having trouble with the Firebase documentation but this video has been so helpful! Thank you!
Thanks for watching 🔥
@anona lol Yeah I'm definitely having a lot of trouble getting things working - I haven't made much progress since this comment as it's hard to find good resources. Net Ninja has a good intro series on his channel, but it doesn't cover enough. His Udemy course has been really good, but it's also outdated. Would love to know if you find any good resources!
Dude - this worked straight away which pretty much never does! :D Subscribed : )
Thanks for subscribing. 🔥🔥🔥
thanks a lot for covering this complex subject, it works flawlessly
Really glad it helped
Great video, you just saved my life, I was reading the documents and after a long time searching, I found your video.
Thanks for your support 🔥
wonderful video for IT Students.
Thanks for the new video on Firebase v9. Great tutorial 🔥
Thank you
thanks! much better than documentation!
would love to see a version where you manipulate the metadata and also set some custom metadata
Sure! Thanks for watching
the best of the best, saved my latenight work, thank you so much!
Glad it helped! Thanks for watching
you saved my life!
the documentation is not clear unlike your video
i have a question>
what is the difference between setDoc() and the method you have used in this video
Hey thanks for your feedback!! Really appreciate it.
Coming to your question setDoc is a method used in firebase firestore (not firebase storage) to add data.
Awesome! Thank you! Man, great tutorial. I was having such a headache with v9 and combing through Firebase docs. Thank you for simplifying this. Liked and subscribed
Thanks for the support! Really appreciate it 🔥🔥
wow dude this was amazing. straight to the point and easy to follow along. much appreciated, thank you!! :)
Thanks for watching 🔥🔥
Beautiful contents useful for all IT students
Thank you
Nice video, man !
When you create functions, they receive some kind of yellow line, what extension is that one?
Bracket Pair Colorizer
Awesome tutorial, thank you!
Is it possible to access Google Cloud Storage (not Firebase Storage) using reactjs?
Typically you need to have a Backend written where you should use google cloud storage, as using it directly in your frontend will expose you secret api keys.
@@FullstackSimplified Makes sense. Thank you! :)
Thanks for you excelent explain! You save me on this part of my project!! Thanks again!!
Thanks very much i begin with firebase and with your tutorial it's was simple :)
Thanks for watching 🔥
Thanks a lot for making this video, Its so precise and bulk with information 🎉🎉🥳🥳👍👍.
Glad you liked it
Since there are 2 ref plugins, it gives the following error. Can you help please?
import { set, ref, } from "firebase/database";
import { getDownloadURL, uploadBytesResumable, ref,} from 'firebase/storage';
Terminal : Parsing error: Identifier 'ref' has already been declared.
You can try alias named import. Something like this
import { set, ref as dbRef } from "firebase/database";
import { getDownloadURL, uploadBytesResumable, ref as storageRef} from 'firebase/storage';
Very useful, thank you. I followed your video and got my test-app working in minutes & was able to use that info for my intended project!
May I suggest you look into using a .env file to protect your firebase credentials from showing up your public github repo? I'm hesitant to leave API keys on public repos - but that's your preference.
Yes surely you can use .env for firebase config. Just for the demonstration I have kept it public and since I have already deleted the project from my firebase console so any ways the api key won’t be usable. But thanks for observation. Really appreciated
I have spent up to two days trying to figure this out. T han you so much for the video. It was amazing. I do need advice, the image is being saved in the storage however it isn't displaying in the storage, its there but i xan't see the actual image. I know it has to do with the file format from expo image picker. I need to convert it to bytes, aby ideas on how to do this? Thank you
Glad it was helpful!
Bu darsdan koʻp narsa oʻrgandim rahmat kottakon
Excellent video man.. Thank you
Thanks for watching 🔥
Hey, this video helps me a lot, but will you please tell me how to display that picture on the web page. Like a person login from the firestore collection and authentication and how do I display his picture as a profile pic.
You can store the download url of the picture in the users collection and then use it when user logs in.
There's another way if you just want to store the img for profile picture only. You can do this by simply setting the display image for your authenticated user by updating the user profile. Follow this for more - firebase.google.com/docs/auth/web/manage-users#update_a_users_profile
Hey There, Thanks for this solution.
But please hear me out,
I want to post a picture along with a caption text to firestore.
so, the imageURL will be sent to storage, and caption text to firestore.
but i am getting errors in doing so. can you please provide some implementation to this
You can store the image to firebase storage then get the download url. Then in the Firestore you need to store the url caption and other details you want. Then everything can be fetched from the Firestore in one go.
Apart from this if you just want to have a caption to your image you can just update the meta data of the image with your custom metadata. Implementation can be found here firebase.google.com/docs/storage/web/file-metadata
thank you, my app worked!
Very helpful content again 🙂
Thanks alot 🤩🤩
Thank you very much dude , it works 😀👌
YOU ARE A LIFE SAVER MAN!
Thanks alot for watching
Thank you very much, Sir !!! you are a real lifeguard 😊😊😊
Thanks for watching 🔥
Hey man great video. I need help. I'm going to use firebase storage to upload files. But I also want to store that url into mongodb, instead of just console.log(url). How can I do that? Sorry I'm a beginner
Once you get the download Url for the uploaded file you can make a request to your backend with the URL as a payload and then in your backend you can store the same in the MongoDb.
Note- Connecting your MongoDB directly to your frontend can be a security issues as you will expose your db api keys and credentials to the public
@@FullstackSimplified Thanks for the reply. Another Question bro. What if I want to upload multiple files. Like Select 1 file then upload like we did here. Staying on the same page. Select another file and upload. Select 3rd file then upload. If that makes sense
Wow, finally, thank you very much. I have seen several videos and could not find the solution. How can we download the image with the V9?
You can directly use the download url in the img element
@@FullstackSimplified thanks you so much
thank u so much for sharing, much needed
Glad it helped. Thanks for watching
@@FullstackSimplified how did you get local host?
How can we fetch this image and use it along with some textual data from the database , like i want to create a card with title , image and description, so the image come from the storage but how can I use title and description which comes for the firebase store and use all this with map function to map all the cards and display them
Hi. You can store the image download url in the database along with other data you have and then you can simply use the url from the response in img src
Love the content.
Thanks for watching
Thank you, man!
10:34 I write console.log(url) and it gives me a working url in Storage, but when doesnt work when i do setImage(url), it pass a empty string, do you know why or how can i fix that?
Please share the code snippet for the same. It will give me more clear context on this.
good tutorial! well done
nicely done, thank you sir
Thanks for watching!!
Very useful, thank you
Thanks for watching
God bless you , thank you brother
Thanks for watching 🔥
How about if we want to have a button that downloads the file that we uploaded directly to our machine
You may try this
Download
can you make part 2 of that using downloading data in firebase
can you make a video of listing all the elements in storage and downloading them ?
Sure. Stay tuned
hi, i follow your instruction and got this error: "Uncaught ReferenceError: ref is not defined" at the line
const storageRef = ref(storage, `/images/${image.name}`);
what is wrong?
Have you imported ref from Firebase storage package?
thank you so much ,this helped a lot
Thanks for watching
How can i save a video in storage and call it in my react app . Where it will play like youtube. Where the files loads in chunks.
Well you can do so by transcoding your video into smaller chunks and uploading it to firebase storage. Then you can store the chunk detials in firestore and download chunks as the video progress.
But this would be really expensive so i would suggest to use some 3rd party solutions like Vimeo or ziggeo. You can also use webrtc of you have your own backend
@@FullstackSimplified thanks
Great content 👍
Thanks alot
This works, however the end is cut short and retreiving the url doesnt work, ive tried it with a global variable and still doesnt work
Hi. You can take a look at the complete code of the project. Links will be in the description.
@@FullstackSimplified I checked it out however, I still cant get to find the way to retreive the url variable outside of the function. I want to be able to add the url to a document in the firestore so I can download it into the UI latter
Great video. But do you know how to call the method to delete a file in this version 9?
github.com/firebase/snippets-web/blob/1c4c6834f310bf53a98b3fa3c2e2191396cacd69/snippets/storage-next/delete-files/storage_delete_file.js#L8-L20
@@FullstackSimplified Excellent. Thanks.
could you do a video just like this but not for react. just for plain javascript and firebase?
Sure will do that!! Stay tuned
@@FullstackSimplified but please make it work. I see RUclipsrs on here that do fire base tutorials and it’s 20222 but for the tutorial they are using fire base 2018
@@FullstackSimplified thanks!
The file is not opening when I download it from the link or directly from firebase storage.
How do I fix this issue ?
It should open, can you share which type of files are you uploading
I tried uploading pdf and jpg.
Also after uploading it shows the file size as 9B for every file I upload
Can you share the code of your upload logic ?
@@FullstackSimplified if (!filestemp) return;
const file=filestemp[0];
console.log(file);
const filename = file.name;
const metadata = {
contentType: `${file.contentType}`
};
const sotrageRef = ref(storage, `files/${filename}`);
const uploadTask = uploadBytesResumable(sotrageRef,file,metadata);
uploadTask.on(
"state_changed",
(snapshot) => {
const prog = Math.round(
(snapshot.bytesTransferred / snapshot.totalBytes) * 100
);
setProgress(prog);
},
(error) => console.log(error),
() => {
getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
console.log("File available at", downloadURL);
});
}
);
Filestemp contains array of file
I am testing it for just a single file first and that single file is taken in const named file
hey I want to store two images so how can i achieve that please guide me
You can select 2 images from the file picker by making it accept multiple images. Then you can loop over the selected images and call the upload function for all the selected images.
Or if you want to select one photo at a time then you can open the file picker twice and upload the selected photos one by one using the same upload function
@@FullstackSimplified Actually I was planning to create separate file picker for both images like profileImage and CoverImage. So will I have to create separate handleImageChange Functions ? Or it can be done in one function itself?
You can use the same function for both. Only thing you need to take care is defining different firebase path/location while uploading the photo
@@FullstackSimplified Thanks!
Hi i am getting error like this Permission denied. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources.
Have you set up storage in your firebase project and set the security rules ? Please follow the video from 04:10
Hello Bro , Could you do a video on how to send the downloadURL to the real-time database?
Sure I'll try to make one asap
@@FullstackSimplified I appreciate Bruh
good explantion
Glad you liked it. Thanks for watching
Thank you so much for the video.
Can someone tell me how to upload an image and an audio together through a single form along with a the name of the song (user specified). Something like an online music player. I've been stuck here for days pls helpp.
You have to upload them separately. Then you can store the download URL for both the files in Firestore or realtime database. Something like
{
name : "Song name",
albumArt : ,
audio :
}
@@FullstackSimplified thank youuu. I did just that and it worked but I've to create some sort of a pause between uploading the file and adding the doc to firestorm.
Currently my adddoc and uploading runs simultaneously so an empty string gets uploaded to firestore since uploading takes some time
You need to add the doc after you receive the download url in that callback
thanks sir
31.comment
Thank you sooooooooooooooooooooooooooooo Much.
You're welcome!
Thanks buddy
Thanks for watching
Hello i have an issue the file is uploaded to my firebase store but appear 9b size and i cant open it.. can you help me?
Do check the file extension, is it corrupted?
Can you do multiple image upload ? And it will be saved in an array.
You can use Promise.all to upload multiple images after selecting them
@@FullstackSimplified can you please do a video for it ? It will be really helpful for us beginners. Thank you
This video help me againd 2x
Thanks for watching again!!
thanks!!!
Awesome video +++++++++++++++++++++++ Thank you
Many thanks!!
multiple files are not getting uploaded, can you tell the solution for this, please
Firebase doesn't allow to upload multiple files. You will have to use loop to upload one by one.
THANKS IT HELPED ME sUSCCRIBED
Thanks for subscribing
How to import more than one picture? More than one input?
Well in firebase you can only upload 1 file at a time. If you want to upload multiple files you will have to loop over your files one by one and upload them using the loop. You can also use Promise.all to resolve the all the promises and then get an array of response
thanks
cool.
i love you
Thanks for watching
you got a like
Thanks alot. Really appreciate your support 🔥
Well, where is the picture!? We must know how to display the image.
You can use the download url in the image element
@@FullstackSimplified Thanks.
how do i delete a folder in storage?
Hi. You can create a ref to the folder you want to delete. Then you can use deleteObject(your_ref) to delete
thank you :')
You're welcome
Simple tutorials are best tutorials.
Keep it up! @wesome
Thanks for watching 🔥
What happens if two files have the same name? Why isn't that really important thing addressed here? One way is to use uid of a currently authenticated user which we can get from auth.currentUser.uid. If your app has multiple files to upload such as cover letter, resume etc they should probably point to different folders. If the user reuploads any of them it will rewrite the previous file in the storage and not fill your storage with duplicates.
Authentication was not covered in this video. It was more about the basics of file uploading. For the file name you can use any thing which suits your application architecture to avoid duplicates or file over riding
Uncaught (in promise) ReferenceError: useState is not defined
Have you imported useState from the react package? Please check
how to download the file??
Using the download URL which we get from firebase after successful uploading of file
@@FullstackSimplified thanks bro how to create sessions for users After signing in ??
Using firebase authentication
Firebase already does that for you. If you still want to override you can refer here firebase.google.com/docs/auth/admin/manage-sessions
@@FullstackSimplified thank you bro u saved me
My screen is now black
Hey there thanks for watching! Can you please share more info about the error!!