how to save Images to the Firebase storage. Android studio | Kotlin.

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

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

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

    how to retrieve images from the firestore: ruclips.net/video/_eTZowmape8/видео.html

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

    Underrated and You are a life saver.. Thank you so much for this

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

    First of all, my humble appreciation for the fantastic tutorial.
    I have searched the net so much and never came across the tutorial which I was exactly looking for until I found this amazing video. I sometimes really wonder why other developers who promise to teach you in very easy steps keep complicating things, while your approach was so smooth and up to the mark
    I found many video, either they still keep using deprecated methods or teach you something that is really not practical. I saw one of the tutors teaching how to save in the firestore storage and then pull the image back to the imageview, AFTER UPLOADING. Seriously??? then I had to search bac and forth just to find the exact video, like I said before, to teach the steps in a way that as it should be.
    Thank you very much, jazakallahu khair, may Allah reward you for this social service that you are doing, aameen!

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

    what a great video sir, its very useful for me and also waiting for next video of part 2 on retrieve image in RV

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

      You're welcome. Sub for next if you haven't already done. And recommend the channel to your friends.

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

      here you have it: ruclips.net/video/_eTZowmape8/видео.html

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

    thanks for it

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

      You're welcome. Subscribe for more. I'm going to make the same playlist for Jetpack Compose.

  • @Amir-xd9le
    @Amir-xd9le 4 месяца назад

    ایرانی پرچمش بالاس🤙🏻

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

      فدای شما

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

      من یه کانال فارسی هم دارم اگر دوست دارید اونو سابسکرایب کنید. اندروید گیک رو سرچ کنید پیداش میکنید.

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

    Dear Sir. I have a question. I run android studio on genymotion xiaomi note 7 virtual machine device. But there are no photos in that virtual machine. So how do I download the photos I want?

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

      You can download them by your pc then transfer them in the emulator.

  • @meetjasani8452
    @meetjasani8452 3 месяца назад

    How to save drawable image in firebase in compose ??pls explain

    • @MohsenMashkour
      @MohsenMashkour  29 дней назад

      To save a drawable image to Firebase Storage in Jetpack Compose, you can follow these steps:
      Add Dependencies: Ensure you have the Firebase Storage dependency in your build.gradle file:
      groovy
      Copy code
      implementation 'com.google.firebase:firebase-storage-ktx:'
      Get the Drawable: Load your drawable resource. You can convert it to a Bitmap, which is necessary for uploading to Firebase.
      kotlin
      Copy code
      import android.graphics.Bitmap
      import android.graphics.drawable.Drawable
      import androidx.compose.ui.res.painterResource
      import androidx.compose.ui.platform.LocalContext
      import android.graphics.drawable.BitmapDrawable
      @Composable
      fun getBitmapFromDrawable(drawableId: Int): Bitmap? {
      val context = LocalContext.current
      val drawable: Drawable = painterResource(id = drawableId).toBitmapDrawable(context)
      return (drawable as? BitmapDrawable)?.bitmap
      }
      fun Drawable.toBitmapDrawable(context: Context): Drawable {
      return BitmapDrawable(context.resources, Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888))
      }
      Upload to Firebase: Once you have the Bitmap, you can upload it to Firebase Storage. Convert the Bitmap to a ByteArray before uploading.
      kotlin
      Copy code
      import com.google.firebase.storage.FirebaseStorage
      import java.io.ByteArrayOutputStream
      fun uploadImageToFirebase(bitmap: Bitmap, imageName: String) {
      val storageReference = FirebaseStorage.getInstance().reference.child("images/$imageName")
      val baos = ByteArrayOutputStream()
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos)
      val data = baos.toByteArray()
      val uploadTask = storageReference.putBytes(data)
      uploadTask.addOnSuccessListener {
      // Handle successful upload
      }.addOnFailureListener { exception ->
      // Handle unsuccessful uploads
      }
      }
      Combine Everything: You can combine these functions in your Composable to save the drawable image when needed:
      kotlin
      Copy code
      @Composable
      fun SaveImage() {
      val bitmap = getBitmapFromDrawable(R.drawable.your_image)
      bitmap?.let {
      uploadImageToFirebase(it, "your_image_name.jpg")
      }
      }
      Summary:
      Load the drawable as a Bitmap.
      Convert the Bitmap to a ByteArray.
      Upload it to Firebase Storage.

  • @johnportelance3851
    @johnportelance3851 11 месяцев назад

    Does this only work on fragments? I do not use fragments. the code works great with one exception? Would you know why my gallery does not come up like your did? mine for some reason does not show the gallery for me to choose a picture? it show stuff like Bug Report -- Drive - My files - Onedrive - System traces But No Gallery at all??? In My part where is Says at the top _ Open from - it only has recent then images then downloads then my phone name then the above mentioned items but no Gallery.
    if I choose Images - I do see my phone images but the are faded or greyed out and I can not select any of the images?? Please help if you can with this issue and thank-you

    • @MohsenMashkour
      @MohsenMashkour  11 месяцев назад

      Hey. You can use it on activities as well. I do not know what is wrong with your gallery.

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

    how to convert it to firestore
    Please reply

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

      I don't understand what do you mean. Firebase storage is called firestore.

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

      If you want to fetch the image to the phone watch this video ruclips.net/video/_eTZowmape8/видео.html