Upload Images / Files to Firebase In React - Firebase V9 File Upload Tutorial

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024
  • UPLOAD IMAGES IN REACT USING FIREBASE. In this video I will go over how to use Firebase storage to upload images in React!
    Code: github.com/mac...
    Join our Discord: / discord
    🚀 Learn ReactJS By Building 6 Projects: codedamn.com/l...
    🐙 GraphQL Course: codedamn.com/l...
    ► Buy Crypto on Coinbase: coinbase-consumer.sjv.io/PedroTech
    Social
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    Website: machadopedro.com
    Linkedin: / machadop1407
    Instagram: / _pedro.machado_
    Github: github.com/mac...
    Business Email: pedro@pedrotech.co
    Tags:
    - ReactJS Tutorial
    - ReactJS and MySQL
    - NodeJS Tutorial
    - API Tutorial
    #reactjs #firebase

Комментарии • 236

  • @Lorkisen
    @Lorkisen Год назад +52

    This was so much easier to understand than the official documentation. Thank you

  • @Human_Evolution-
    @Human_Evolution- 2 года назад +4

    This is the best video on the very basics. A part 2 with a orderBy and delete option would be OP AF.

  • @eleazarhernandez805
    @eleazarhernandez805 7 месяцев назад

    Dude, really appreciate the approach. You are a clear-spoken and intelligent individual. Keep it up!

  • @VickTechPro
    @VickTechPro 2 года назад +3

    Hey Pedro, I love watching your tutorials. They are easy to follow and explained quite well.
    I just had another request, like can you please also make videos on some popular NPM libraries and how to use them in our codebase. That would really be helpful for a lot of people like me who rely on NPM libraries on a daily basis but can't find enough tutorials to fully understand their usage.

  • @joshuaborseth
    @joshuaborseth 2 года назад +3

    This is perfect. I was just about to add image uploading functionality to my project. Thanks Pedro!

  • @alexandrewilk2000
    @alexandrewilk2000 2 года назад +1

    Pedro tech I followed all your firebase tutorial they r all BANGERS I LOVE YOU

  • @ashikmahmud4076
    @ashikmahmud4076 2 года назад +3

    This is the video which one need now my situation. Thanks bruh by the way I am new subscriber of you channel.

  • @nguyenhuynhtrung8254
    @nguyenhuynhtrung8254 2 года назад +2

    i followed your guide and it work very well, except there is one thing. The image keeps being duplicated many time. Any fix for this. I have checked all the code in your video but no clue.

  • @alessiapiscopo
    @alessiapiscopo 2 года назад +3

    Thank you so so much for this! You manage to make things super clear and easy to understand and it's just great. Thanks again :)

  • @pablom8854
    @pablom8854 9 месяцев назад +10

    Just adding extra timestamps for me in the future:
    1:40 Firestore & project setup
    4:10 Neccesary packages
    5:00 Storage - get started
    6:30 Firebase configuration
    Working in the React app
    8:30 Adding file input and btns
    11:23 Uploading an image(firebase code)
    13:25 Randomize image name
    14:50 Upload the image to firebase
    16:48 How storage works
    17:20 Display all images in the React app
    23:25 Show new uploaded images automatically

  • @fantasticyuvi8104
    @fantasticyuvi8104 Год назад +1

    i HAve updated the rules section but after running the app it is showing warning of " Missing Permission " due to firestore , and every time i run the app , a dialog box appears showing this and i need to close that then i am able to access the app , if it keeps that wway then i think it will have problems in deploying the app

  • @tahep3906
    @tahep3906 Год назад

    thank you very much for this simple project which helps to easily understand the basic concepts behind the upload process to firebase, I've just recently watched a video to do with this subject, it was simply a nightmare comparing to this one, it was like running without learning to walk :), huge thanks again

  • @QuayneBrown
    @QuayneBrown Год назад

    Thank you Pedro. Been looking for a video like this for a while now.

  • @turki8542
    @turki8542 2 года назад +1

    what if i want to have a search bar for the user to search for a specific file and then display that file. how can i do that
    Thanks

  • @Andreas-hy7ob
    @Andreas-hy7ob 2 года назад

    This was really well explained, its clear to see you got a passion! Keep going at it man, its truely great!

  • @victorross5524
    @victorross5524 2 года назад

    Thanks Pedro, of course i will leave the like, its the least i can do for this great content.
    Thanks again from Brazil!

  • @marcelomalagra1613
    @marcelomalagra1613 2 года назад +2

    Straight to the point, thanks Padro!

  • @fearquare
    @fearquare 5 месяцев назад

    I really loved your video!! Thank you for uploading this, it really helped me.

  • @pro4erb
    @pro4erb 2 года назад +1

    this is the best video on the planet! why use drive api when you can do the same but in the easiest way possible🤩

  • @codewithdevhindi9937
    @codewithdevhindi9937 2 года назад

    i really love watching your LEGENDARY videos with awsome explainaton

  • @andrewsmal5173
    @andrewsmal5173 2 года назад +1

    Please make a video about Firebase security!!!!!!!! Please

  • @JitenderMediaX
    @JitenderMediaX Месяц назад

    this was awesome thanks for making this. keep making this helpful content 👌👍🙏

  • @wojteknowak8946
    @wojteknowak8946 Год назад

    You are my role model, thank you for this tutorial Pedro ;)

  • @talalkhan1873
    @talalkhan1873 9 месяцев назад

    sir g zindabad.. wada wada laav u hogya e qasmay

  • @TheOhmagad
    @TheOhmagad Год назад

    Exactly what i was looking for. Great explanation. Thank you

  • @fosimuboolubo8891
    @fosimuboolubo8891 2 года назад

    I'm so happy I came across your channel. I've been searching for videos on various aspects of firebase. Thanks man. Don't know if you mind doing a video on how to link stripe payment gateway to firebase. I'm planning on creating a dummy e-commerce site for my portfolio, and would like to integrate a payment gateway. I tried to get tutorials how to do it, but they are quite confusing.

    • @fosimuboolubo8891
      @fosimuboolubo8891 2 года назад

      Still on the payment integration, I noticed most of the tutorials I saw on stripe integration all had to do about firebase cloud functions. Is that the only way to integrate stripe to a web app?

  • @poorna_recharla
    @poorna_recharla 2 года назад +1

    Another awesome video. Really useful for my new project.
    Could you please do a video on pagination using firestore?

  • @hammudi6790
    @hammudi6790 2 месяца назад

    will there be a tutorial with using react, node, express and mysql? would appreciate it

  • @tashinamgay7922
    @tashinamgay7922 2 года назад +1

    Thank you for the video. Btw, can anyone tell me how to link some data to that particular upload (like name, date uploaded, etc) please.

  • @HI-ks4pr
    @HI-ks4pr 2 года назад

    非常に分かりやすく、学習の助けになりました。ありがとうございます。

  • @michelsegnon
    @michelsegnon Год назад

    Thanks for this wonderful tutorial. Very clean

  • @rudra5050
    @rudra5050 2 года назад +1

    Please Will you make a video on how to send data and files to firebase from one js file.

  • @rebazjabar7660
    @rebazjabar7660 Год назад

    i implemented this on next js it work thanks alot dear

  • @charbelmansour8925
    @charbelmansour8925 2 года назад +1

    PEDRO TO 100K LETS GO

  • @Ribhav.Singla
    @Ribhav.Singla 3 месяца назад +1

    worth watching it

  • @maskman4821
    @maskman4821 2 года назад

    This is really awesome, it would be wonderful if you can demo how firebase push notification work 🥰

  • @anazi
    @anazi Год назад

    Thank you man 👍👍 I got stuck for like two days on tutorial that have firebase 8 not firebase9 so I could not proceed. Thanks again.

  • @muzardemoses
    @muzardemoses Год назад

    Great Stuff, what if only want to show the image I just upload and use it as profile picture. I will be glad if you give me an answer to that

  • @RockstarGamer4531
    @RockstarGamer4531 2 года назад

    Hey Pedro i had a question that i understand how to add image in firebase storage but will you please tell that how to reference a particular image to a particular document of firestore dynamically ?

  • @gotjuked8682
    @gotjuked8682 2 года назад +2

    Hi I have an issue regarding the listAll() method. When ever I use that method it re-renders all the codes multiple times, as a result it saves a duplicate of each downloadUrl.

  • @NezNez
    @NezNez Год назад +1

    Thanks for the video! Is it safe to store all your api keys on frontend code like that? So basically anyone could upload some terabytes to your bucket and you get billed for that... ?

  • @StrapyProject
    @StrapyProject Год назад

    bro u need to do a delete image from firebase storage and user id, pls for your next content in follow up to this one

  • @supercoolcat7692
    @supercoolcat7692 2 года назад

    Thanks Man. I appreciate your videos

  • @PawelMisiura
    @PawelMisiura Год назад +1

    If anyone needs here is the useEffect code that wont add extra images on refresh :
    useEffect(() => {
    const fetchImages = async () => {
    let result = await listAll(imageListRef);
    let urlPromises = result.items.map((imageRef) => getDownloadURL(imageRef));
    return Promise.all(urlPromises);
    };
    const loadImages = async () => {
    const urls = await fetchImages();
    setImageList(urls);
    };
    loadImages();
    }, []);

  • @RyanBlair-xh2sy
    @RyanBlair-xh2sy Год назад

    Hey thanks for the great videos!! I was wondering if you could show how to store the link to the image in a firestore database

  • @mohamedhakim8336
    @mohamedhakim8336 8 месяцев назад

    a very helpful video. Thank you

  • @chrisamuzie401
    @chrisamuzie401 2 года назад

    Thank you for the great tutorial bro.. can you please make a video for firebase function. Most especially a function that can run on it's own at a given time just like cron-job

  • @dreamArmy34
    @dreamArmy34 Год назад

    hey I want to store two images so how can i achieve that ?

  • @WalidAra
    @WalidAra 9 месяцев назад

    followed same steps and didnt work , but just to let you know i m trying to upload videos however i could upload it but when i try display it something goes wrong

  • @xMarcakizen
    @xMarcakizen 2 года назад

    Hello, great video and I managed to do it! But how do I only list the recent added image?

  • @furkangenc7869
    @furkangenc7869 Год назад +2

    If you want upload personal image and download personal image you can use
    const imagesListRef = ref(storage, `images/${user.uid}`);
    or
    const imagesListRef = ref(storage, `images/${auth.currentUser.uid}`);
    but first you must do "Sıgn In" and "Sıgn Out" medhod in reactjs with firebase
    and
    useEffect(() => {
    if (user.uid) {
    const imagesListRef = ref(storage, `images/${user.uid}`);
    listAll(imagesListRef).then((response) => {
    response.items.forEach((item) => {
    getDownloadURL(item).then((url) => {
    setImageList((prev) => [...prev, url]);
    });
    });
    });
    } else {
    return;
    }
    }, [user]);
    your useeffect must be like that becaouse when your page loading user accaount or auth progress not finished. Your useEffect must be relative to "user" or relative to "auth"

  • @human_justice
    @human_justice Год назад

    Hey thanks for the tutorial. I am working on a blog and I want to display only the images I uploaded for the blogpost. Any Idea?

  • @devsilva7155
    @devsilva7155 2 года назад

    me fue de mucha ayuda tu vídeo, pero de que manera puedo mostrar las imágenes que suban a un carrusel y de que manera puedo usar un custom hook que haga las imágenes que se muestren sea re utilizable para mostrarlas en otros lados?

  • @Llytkm
    @Llytkm 2 года назад

    Hi is it possible to upload an image along with some text for the image and show it.

  • @chinedutagbo9859
    @chinedutagbo9859 2 года назад

    hey thanks for the video but I have an issue. Every time I map through the imagelist, it renders the images continuously and doesnt stop. help please

  • @BrunoOliveira-Bling
    @BrunoOliveira-Bling Год назад

    great video! ty!

  • @abeechr
    @abeechr Год назад

    QUESTION: Can I save an image file directly to firebase using an URL? Or do I need to download it to localStorage first and then back up? I am making app using Dalle2 images which generates image URLs which only last a few hours. Thanks!

  • @13hpca
    @13hpca 2 года назад

    Parabéns man!
    Video muito bom!

  • @jare3582
    @jare3582 2 года назад

    for mapping the files, do we always use the "url" or is there another thing that we can use it to loop in
    thanks for your content

  • @filipevalentegomes2383
    @filipevalentegomes2383 2 года назад

    I watched your video on CRUD with Firebase. Let's say I have a bunch of users stored in the firebase database, what would I have to do to let them upload an image that is linked under their info on the database where their info is stored. Im asking cuz this shows how to upload on firebase storage, but not how to link it to a firebase database. Hope my question makes sense to you

  • @annaGoannaTheGoanna
    @annaGoannaTheGoanna Месяц назад

    THUMBS UP!

  • @riiya7928
    @riiya7928 2 года назад

    How about if I just want one item?

  • @jss_developer1432
    @jss_developer1432 Год назад

    I find the documentation really hard to follow.
    Would you be able to provide a cheatsheet or an easier guide to folllow ?

  • @bmp713
    @bmp713 2 года назад

    What should you do if the file path says "C:\fakepath\Image-to-upload.png"?

  • @Glopzu
    @Glopzu 4 месяца назад

    you are aweome!

  • @daniishhhh
    @daniishhhh 2 года назад

    thnks bro . realy helpful

  • @nickciambrone
    @nickciambrone Год назад

    its not working with pdfs. any idea why?

  • @un_chien_andalou
    @un_chien_andalou 2 года назад

    Thanks, man! :)

  • @MOHITRANA-to7rf
    @MOHITRANA-to7rf Год назад

    how to store image and text simultaneously

  • @sivkayyinh2942
    @sivkayyinh2942 2 года назад

    Can you show me how to handle error for that?

  • @ikamy
    @ikamy 2 года назад

    I get Unkown error While trying to download images

  • @AlameenAdeyemi
    @AlameenAdeyemi Год назад

    But it would really be nice if you added the feature of how to delete

  • @filip23128
    @filip23128 Год назад

    Thanks!

  • @mohammed_basher
    @mohammed_basher Год назад

    you rock!

  • @huyhai922
    @huyhai922 22 дня назад

    thank you

  • @JoeOsborneMusic
    @JoeOsborneMusic Год назад

    LEGEND

  • @maxvhanamane840
    @maxvhanamane840 Год назад

    Hi Pedro, Is it safe to expose firebase config in frontend?

  • @robertmacwan8144
    @robertmacwan8144 2 года назад

    thanks 👍

  • @rameshsrivastavachandra
    @rameshsrivastavachandra Год назад

    Thanks

  • @PeriklesPeriklesoglu
    @PeriklesPeriklesoglu Год назад

    thank you

  • @samsuriahmad2128
    @samsuriahmad2128 Год назад

    How about txt file...

  • @dvlnx.
    @dvlnx. 2 года назад

    it didnt work for typescript

  • @web_resource
    @web_resource 5 месяцев назад

    Upload image - 15:33
    Retrieve image - 21:35

  • @BCSMohdHaider
    @BCSMohdHaider 2 года назад

    I want to delete image how I an do it in react

  • @ThColinPereira
    @ThColinPereira 2 года назад

    Niceeeee!

  • @clarcktumazar
    @clarcktumazar 2 года назад

    I got an CORB errors when I tried to put the URL inside the img tag HELP HAHA

  • @xuqiangzhang9724
    @xuqiangzhang9724 2 года назад

    nice!

  • @pugsinc.6959
    @pugsinc.6959 2 года назад

    i have this error: Cannot POST

  • @jobanarora7329
    @jobanarora7329 Год назад

    thums up

  • @anounTT
    @anounTT Год назад

    "snaphsot" 😄

  • @denversupermarket7484
    @denversupermarket7484 Год назад

    anyone else unable to solve CORS issues here?

  • @jellyfish1772
    @jellyfish1772 10 месяцев назад

    You are stroing all your api information directly in your client code.thats not very safe.

  • @nemanja3394
    @nemanja3394 2 года назад +8

    This is very useful thank you.
    But how would you upload images for specific items? Let's say that you want to allow users to upload products to the app, product should have a name, price, size and Image. So you create the form and connect it to Firebase database and uploads work fine for strings but with files (images) it's different. So how to connect the storage with code and with specific items in firebase?

    • @mega9686
      @mega9686 2 года назад +1

      I would like this too Hey Pedro would you spare time to make this video i would be very greatful

    • @Ja-rz9fq
      @Ja-rz9fq Год назад

      The key is to use storage just as that - storage, so you upload image to firebase storage and then use the URL and put it in your actual database. Lets say you have Postgresql database and in your app you have a feature to share Posts, so you have Post table in your database, in that table you store values like: id, postName, postCreatedAt... and you also can add postImage and in postImage you store the link to an image stored in firebase storage

  • @zusm
    @zusm 2 года назад +3

    Hey guys, my useeffect that is used to get the image URLs seems to be firing multiple times, and im getting the error "React Hook useEffect has a missing dependency: 'imageListRef'. Either include it or remove the dependency array."
    Any fixes? thanks

    • @PedroTechnologies
      @PedroTechnologies  2 года назад

      This seems like an eslint error! Try either disabling it or adding the single line disable

  • @manipullator
    @manipullator Год назад +1

    I don't know why but it is looping and it is just rendering image atleast 20 to 40 times

  • @utkumattaktas7994
    @utkumattaktas7994 2 года назад +3

    when I console.log(response) I am getting 2 times for the same array. That causes the problem of displaying every image 2 times on the screen. Any idea how can I fix this ?

    • @raydelara7185
      @raydelara7185 2 года назад

      Same, any help?

    • @utkumattaktas7994
      @utkumattaktas7994 2 года назад +1

      @@raydelara7185 i contacted with firebase support they have no idea.

    • @christofstanits
      @christofstanits 2 года назад +2

      the problem is React.StrictMode which causes useEffect to be fired twice in development mode
      remove from index.js and it works as intended

    • @utkumattaktas7994
      @utkumattaktas7994 2 года назад +1

      @@christofstanits that worked thank you . Do you know that I am not using React.StrictMode will cause any problem later ?

    • @christofstanits
      @christofstanits 2 года назад +1

      @@utkumattaktas7994 react strictmode is to check for impure functions. This one is a bit of an edge case, because the function fires twice before the fetch happens.
      if you want to keep strictmode, search "Async Function Adding Elements Twice to an Array in React" on stackoverflow.
      (youtube wont let me post the link)

  • @prashantindurkar
    @prashantindurkar 2 года назад +3

    Thanks i was looking for how to upload files to firebase. i think u should change your vs code theme 🙂

    • @PedroTechnologies
      @PedroTechnologies  2 года назад +2

      Happy to hear hahaha I still am using the same one because I started making a course using it so im only going change it when I am done with my course

  • @nidhishettigar6981
    @nidhishettigar6981 2 года назад +1

    After installing firebase uuid i am geting this error
    Compiled with problems:X
    ERROR in ./node_modules/firebase/dist/index.esm.js
    Module build failed (from ./node_modules/source-map-loader/dist/cjs.js):
    Error: ENOENT: no such file or directory, open 'E:\e-buddy-for-rescued-child-labour\ebuddy-portal
    ode_modules\firebase\dist\index.esm.js'
    please suggest some solution.

  • @suryasuthar9427
    @suryasuthar9427 9 месяцев назад +1

    Hello Pedro , I say that file upload but " many file inputs " in reactjs with using storage and save url firestore .

  • @AlameenAdeyemi
    @AlameenAdeyemi Год назад +1

    This isn't complicated as you said in your firebase tutorial 😂😂