Uploading Images to Firebase Storage in React Native

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024
  • Hello! Welcome to this video. In this video, you will learn how to access Firebase Storage inside React Native.
    If you learned from this video, give this video a thumbs up and subscribe to this channel! To stay updated on all our future videos, click the notification bell!
    Expo Documentation on Firebase: docs.expo.dev/...
    Code: drive.google.c...
    App Development: • App Development
    Don't forget to comment down below on what you want to see next (or if you have any questions)!

ความคิดเห็น • 117

  • @jjrise
    @jjrise 2 ปีที่แล้ว +3

    you are truly a lifesaver... I was searching for hours for why my images weren't uploading properly and your "bytes" fix is exactly what I needed. Thanks!!!!

  • @mihailpetrovici5044
    @mihailpetrovici5044 2 ปีที่แล้ว +1

    THANK YOU, A BLESSING FROM THE SKY, fucked 5 hours trying to write the image as bytes

  • @hoilesy6192
    @hoilesy6192 ปีที่แล้ว

    perfect, i was really need it. You so good

  • @gtasa0629
    @gtasa0629 ปีที่แล้ว +1

    Thank You! . Finally it WORKED....

  • @ahsanahmed2505
    @ahsanahmed2505 2 ปีที่แล้ว

    Thank you! your solution worked after searching all day

  • @microsoftus-eu5323
    @microsoftus-eu5323 2 ปีที่แล้ว

    Truly, simple and complete.

  • @pablosaxgarcia6349
    @pablosaxgarcia6349 ปีที่แล้ว

    OMG! Thank you very much. Best tutorial ever.

  • @zaithelcardoza8394
    @zaithelcardoza8394 2 ปีที่แล้ว

    Thank you so much!!!!!!!!!!!!!!!!
    This was totally what I was looking for.
    You are amazing!

  • @jey4s544
    @jey4s544 2 ปีที่แล้ว

    Thank you a bunch, it's been 2 weeks of pain and nail biting 😅 make more videos

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      loll, same for me when I was first trying to solve this issue. I'm glad this helped!

  • @johncmm9759
    @johncmm9759 2 ปีที่แล้ว +1

    Fantastic video! Thank you so much for putting this up! Short, simple explanation of a recently-emerged complex problem, and straight to the point :)

  • @zensic
    @zensic 2 ปีที่แล้ว

    Thank you! This was very straightforward!

  • @junaidanwar9960
    @junaidanwar9960 2 ปีที่แล้ว

    thank you so much you just code the same as I wanted the one..keep it up

  • @nilsmassing5376
    @nilsmassing5376 2 ปีที่แล้ว

    Thanks for this video, was really helpful! :)

  • @dailydowcip5569
    @dailydowcip5569 ปีที่แล้ว

    THANK YOU SO MUCH

  • @practicacodigo9119
    @practicacodigo9119 2 ปีที่แล้ว

    Hello, thank you so much, aunque ya lo sabía pero lo explicas bien jajaja, I love you

  • @digveshparab8254
    @digveshparab8254 2 ปีที่แล้ว

    thank you ,really helpful video 🔥

  • @juliolemosdf
    @juliolemosdf 7 หลายเดือนก่อน

    can you help me? It's giving this error: WARN Possible Unhandled Promise Rejection (id: 0):

  • @yeloda777
    @yeloda777 2 ปีที่แล้ว

    Thanks a lot ! i spent 2hours trying to figure out what was wrong, i just didn't convert the image uri with blob !

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      that's an easy thing to miss, glad this helped

  • @joseadanobregonbarillas2934
    @joseadanobregonbarillas2934 2 ปีที่แล้ว

    THANKSSSSSSSSS YOU ARE AMAZING

  • @vsowill
    @vsowill 2 ปีที่แล้ว

    Thank you so much 🙏🙏🙏🙏🙏You would think uploading a profile image would be simple smh lol but nothing is simple with Firebase and Expo 😂

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      lol, happy to help :D

  • @scrubbydubbie
    @scrubbydubbie 2 ปีที่แล้ว

    actual life saver

  • @Anas-pr7le
    @Anas-pr7le 2 ปีที่แล้ว

    Short and well-explained. Thank you so much!

  • @mhazizk
    @mhazizk ปีที่แล้ว

    There is an issue with uploadbytes in expo 47, firebasejs 9, and expo custom dev client. Whenever it starts uploading, the promise never resolves nor rejects, so it is impossible to see the cause of the error. Anyone knows the hack to make it uploadbytes work? I desperately look for answers but none of them works

  • @admirljubovic6759
    @admirljubovic6759 2 ปีที่แล้ว

    THANK YOU SO MUCH

  • @mattb7113
    @mattb7113 ปีที่แล้ว

    Hi there, I'm trying to get this to work for Video upload but it doesn't work. The image picker works and allows you to pick videos, so I assume uploadBytes doesn't allow videos? Any idea

    • @the_whiz
      @the_whiz  ปีที่แล้ว

      I can't find any functions for video so uploadBytes should work? I would suggest looking at the rest of your code to see if there is something wrong there.

  • @ahmadankadev
    @ahmadankadev 2 ปีที่แล้ว +1

    it keeps crashing on ios when uploading a video than tis larger than 2mb , any idea why ?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      do u have an error message? if it is just taking long time, a 2mb video is pretty big. I'm not really familiar with ways to optimize, but you could start a github error on firebase or react native

  • @hyrixlele8959
    @hyrixlele8959 2 ปีที่แล้ว +1

    why am i getting this error ? : Error: Requiring module "node_modules\firebase\app\dist\index.esm.js", which threw an exception: ReferenceError: Can't find variable: IDBIndex

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      make sure you have the right version of firebase installed. some peps said that it didn't work with v9, but v8 of firebase, so maybe try that?

    • @quickcompilations1714
      @quickcompilations1714 2 ปีที่แล้ว

      I get the same error here 🤔 I heard it might be a bug

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว +1

      @@quickcompilations1714 i looked into the firebase github repo, and it seems like there are lots of comments about a bug

    • @quickcompilations1714
      @quickcompilations1714 2 ปีที่แล้ว

      @@the_whiz shooooot yeah it sucks, I guess we'll just have to wait until it gets fixed

  • @surayuthpintawong8332
    @surayuthpintawong8332 2 ปีที่แล้ว +1

    Thanks. I'd stuck for hours. It turned out that the most important step is to allow the user to read/write to the storage first.

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      haha, yep, that gets me tricked every time :) glad you got it figured out

  • @balimuttajjofrancis1002
    @balimuttajjofrancis1002 2 ปีที่แล้ว

    thanks alot

  • @realvoices2356
    @realvoices2356 ปีที่แล้ว

    Hi, I can not upload multiple images once. Anyone have solution?
    Thanks advance!

    • @the_whiz
      @the_whiz  ปีที่แล้ว +1

      I would recommend iterating through a list with all the files within it and uploading them one by one

    • @realvoices2356
      @realvoices2356 ปีที่แล้ว

      @@the_whiz thanks you. I has tried and successfully upluad multiple images but can not upload one image now, I use firebase 9.15.0. Have you tried this firebase version and do you have problem like me?
      Thanks

  • @muhammadusama-1
    @muhammadusama-1 2 ปีที่แล้ว

    How can i get URLs for uploaded images from uploadBytes methods to store the URLs of images in the collection?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      Video created! th-cam.com/video/IZNDDIQtt-s/w-d-xo.html

  • @talbertherndon1925
    @talbertherndon1925 2 ปีที่แล้ว

    Could you do a tutorial on how to actually get this image from the firebase storage

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      Video created! th-cam.com/video/IZNDDIQtt-s/w-d-xo.html

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 ปีที่แล้ว

    Awesome Video ++++++++++++++++++++++++++++++++++++++++++ Thank you

  • @AbdullahAli-rg8ug
    @AbdullahAli-rg8ug 2 ปีที่แล้ว

    img.blob() is not a function. (img.blob is undefined)
    i am getting this error

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      this is probably caused by what version of firebase you are using. I recommend that you use the one that I have in the video.

  • @osmanmohamed8374
    @osmanmohamed8374 2 ปีที่แล้ว

    it is working fine in IOS but not working at all in Andriod devices

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      might be something in ur android version code because this should work in both ios and android. feel free to send what code you used and I can try to debug it from there.

  • @lulzimfazlija
    @lulzimfazlija 2 ปีที่แล้ว

    Do you have any idea why fetching images from firebase storage is so slow? I tried to make the whole bucket public still slow compared to other resources!

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      this is my speculation, but I think that react native to firebase is not that developed in documentation and such, so maybe it is just not as fast in react native as they make app -> firebase smoother

  • @kcash935
    @kcash935 2 ปีที่แล้ว

    Awesome video, thanks so much for this. I had a quick question. I'm making an Instagram clone and I have it where they select the image on one screen before it transitions to another to actually upload. Am I able to simply pass the image as a parameter through react navigation, then use it with the function you created and just replace result with the image variable?
    As well, when I do this, I get ".blob() is not a function". Sorry if my info is kind of vague.

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว +1

      you may be passing in a url or a name of the image instead of the image itself. that would be the most likely error.

    • @kcash935
      @kcash935 2 ปีที่แล้ว

      @@the_whiz Figured it out. Hadn't set up the request for permissions using the useEffect. Appreciate your help!

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว +1

      @@kcash935 awesome, I'm glad you solved it!

  • @brnbk8910
    @brnbk8910 2 ปีที่แล้ว

    my code worked, but it only sends the first image, it doesn't send another, even different images, does anyone have this problem?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      I think that you should have a refresh page button that recalls and gets the image. or is that not the issue?

    • @brnbk8910
      @brnbk8910 2 ปีที่แล้ว

      @@the_whiz no, the image goes to firebase, but only the first one, then no more images

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@brnbk8910 check whether the function is called or whether you are changing the image that is sent to the database.

  • @talbertherndon1925
    @talbertherndon1925 2 ปีที่แล้ว

    the ref doesnt work... not sure what the problem is for me

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      could you send your code or explain the problem more?

    • @talbertherndon1925
      @talbertherndon1925 2 ปีที่แล้ว

      @@the_whiz Easy fix , I just changed the variable name to something other than "ref" , apparently you cannot use it as a variable name and take the same name from the package

    • @talbertherndon1925
      @talbertherndon1925 2 ปีที่แล้ว

      This is the best tutorial on youtube for this . SO THANK YOU SO MUCH!!!!! Please keep making videos

  • @riskitall7421
    @riskitall7421 2 ปีที่แล้ว +1

    Hey Whiz, images may upload with this code, but videos crash the app in iOS. Any ideas?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      This may be because of the packages you installed because the code works (since I've tested it)
      Can you send over your package.json? Make sure you have firebase installed.

    • @riskitall7421
      @riskitall7421 2 ปีที่แล้ว

      @@the_whiz I switched to v8.10.0 and now it's working as expected.

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@riskitall7421 Perfect!

    • @adriatorres2918
      @adriatorres2918 2 ปีที่แล้ว

      @@the_whiz Hey, in my case, using your code, app even crashes when uploading images. Why?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@adriatorres2918 are you on android or ios? also, even though you downloaded my code, you still have to install the packages yourself into the place you used my code in.

  • @lulzimfazlija
    @lulzimfazlija 2 ปีที่แล้ว

    it keeps crashing for me for certain images when using the firebase sdk uploadBytes()! Any idea why keep crashing?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      this is most likely a firebase issue, but also could be due to corruption or something that cannot be interpreted in your image.

    • @ahmadankadev
      @ahmadankadev 2 ปีที่แล้ว

      am having the same problem on ios did you find any solution ?

    • @lulzimfazlija
      @lulzimfazlija 2 ปีที่แล้ว

      @@ahmadankadev no I didnt, and I gave up on that :poop firebase bc it also too slow fetching images, Cloudinary works really great altho it seems abit expensive

    • @ahmadankadev
      @ahmadankadev 2 ปีที่แล้ว

      I solved my problem by routing the upload request to a php server then uploading to the firebase from there

  • @AbdullahAli-rg8ug
    @AbdullahAli-rg8ug 2 ปีที่แล้ว +1

    TypeError: Network request failed]
    at node_modules/whatwg-fetch/dist/fetch.umd.js:535:17 in setTimeout$argument_0
    i m getting this error too

    • @elainefang2001
      @elainefang2001 2 ปีที่แล้ว

      i have the same error too😓

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@elainefang2001 a set timeout argument error is probably caused by the permissions you have within firebase. for the purposes of this video, make sure that you have:
      service firebase.storage {
      match /b/fir-storageproject-a0a7d.appspot.com/o {
      match /{allPaths=**} {
      allow read, write;
      }
      }
      }

  • @TheSnakebite2000
    @TheSnakebite2000 2 ปีที่แล้ว

    I'm getting this error not sure what is wrong?
    [Unhandled promise rejection: TypeError: (0, _Firebase.fbStorage) is not a function. (In '(0, _Firebase.fbStorage)()', '(0, _Firebase.fbStorage)' is an instance of FirebaseStorageImpl)]

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      It may be because you did something like
      const ref = ref(...)
      In this case, you are using the ref function and ref as a variable, so make sure the ref variable is named something different.

    • @TheSnakebite2000
      @TheSnakebite2000 2 ปีที่แล้ว

      @@the_whiz I changed that and still the same thing, is it possible that storage in fire base doesn’t work with react native anymore? Or Node.js?

    • @TheSnakebite2000
      @TheSnakebite2000 2 ปีที่แล้ว

      When u tried uploading to storage in your app did it work fine?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@TheSnakebite2000 Yes, it may be because of your firebase version. For lots of people, it doesn't work unless you use version 8.10.0 I believe

    • @TheSnakebite2000
      @TheSnakebite2000 2 ปีที่แล้ว

      @@the_whiz I’m currently using version 9.6.7 and I’m writing all my firebase code using firebase V9, authentication & Firestone work fine just having issues with storage

  • @cedagio1624
    @cedagio1624 2 ปีที่แล้ว +1

    I couldn't upload my images. I get this error message
    "[Unhandled promise rejection: TypeError: ref is not a function. (In 'ref(storage, 'image.png')', 'ref' is undefined)]"

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      Make sure that you import ref into your project! also make sure that firebase has the right version number

    • @anandvishwakarma933
      @anandvishwakarma933 2 ปีที่แล้ว +4

      Hi, I tried the below changes, it worked for me:
      if (!result.cancelled) {
      const storage = getStorage(); //the storage itself
      // const ref_con = ref(storage, 'image.jpg'); //how the image will be addressed inside the storage
      const ref_con = ref(storage, new Date().toISOString()); //how the image will be addressed inside the storage
      //convert image to array of bytes
      const img = await fetch(result.uri);
      const bytes = await img.blob();
      await uploadBytes(ref_con, bytes); //upload images

    • @zaithelcardoza8394
      @zaithelcardoza8394 2 ปีที่แล้ว

      @@anandvishwakarma933 Thank you, this worked like a charm

    • @Anas-pr7le
      @Anas-pr7le 2 ปีที่แล้ว

      @@anandvishwakarma933 thank you soo much bro. I think variable ref and ref() were conflicting due to their same names. Working like a charm now.

    • @tanny3080
      @tanny3080 2 ปีที่แล้ว

      @@anandvishwakarma933 Thanks. you save my life bro

  • @kritgupta5051
    @kritgupta5051 2 ปีที่แล้ว

    This does not work for videos.

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      does this help? medium.com/react-native-training/uploading-videos-from-react-native-c79f520b9ae1

  • @davidshapirofilms3180
    @davidshapirofilms3180 2 ปีที่แล้ว +1

    Hi, I want to first thank you for such a clear and helpful tutorial! I am having some trouble though. I got my app to upload images to firebase however both the simulator and the app running on my phone through Expo will sometimes crash when I add an image but will sometimes be ok. It seems almost random. I'm totally stumped. Any idea why this might be occurring?

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว +1

      It might be the type of image is not supported. For example, if you are storing it as a .jpg, then .png files might crash.

    • @qiqiliang7793
      @qiqiliang7793 2 ปีที่แล้ว

      @@the_whiz i am having the same issue when i am on production mode (TestFlight), but on expo go or simulator is fine. and there is no error message, and i do not know how to fix it

    • @qiqiliang7793
      @qiqiliang7793 2 ปีที่แล้ว +1

      @@the_whiz OMG!! You are RIGHT! i am setting the img to jpg, but uploading a png img!!! thanks you are amazing!!!!1

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@qiqiliang7793 yeah np! glad it helped!

    • @davidshapirofilms3180
      @davidshapirofilms3180 2 ปีที่แล้ว +2

      @@the_whiz Thank you! I think for me that it crashes if I try to upload another before it has finished the first… so I think I’m all set!

  • @damianocaffa8661
    @damianocaffa8661 2 ปีที่แล้ว

    great video and very helpful. Cheers!

  • @rog0079
    @rog0079 2 ปีที่แล้ว

    Saved my day!

  • @natnice2574
    @natnice2574 2 ปีที่แล้ว

    Thank you soo much!! I have a question... how could i then display the image I have now uploaded to firebase to be someones profile picture? (I am making an app similar to tinder)

    • @natnice2574
      @natnice2574 2 ปีที่แล้ว

      I tried something like this but im pretty sure its wrong
      await updateDoc(doc(db, "users", user.uid), {
      imageURL: uploadBytes,

    • @the_whiz
      @the_whiz  2 ปีที่แล้ว

      @@natnice2574 Video created! th-cam.com/video/IZNDDIQtt-s/w-d-xo.html

    • @natnice2574
      @natnice2574 2 ปีที่แล้ว

      @@the_whiz Wow thanks so much!!