Get images from firebase storage and realtime database

Youssof Elgohary :

So, I wanna make the user upload multiple images at the same time to firebase storage. I have done that part successfully but now I want to retrieve the images back. At first, I was uploading one image per user and save the image id to the realtime database so it was very easy to retrieve the image back by the image id. But now how can I save more than one image to the realtime database per user I can't use the same child name because it will be replaced with the old one. Any ideas??

Uploding images and setting the id on realtime database:

private void Fileuploader() throws FileNotFoundException {
        String imageid;

        progress.showProgress(profuctadd.this,"Loading...",false);
        DatabaseHelper databaseHelper = new DatabaseHelper(profuctadd.this);
        Cursor getimage = databaseHelper.GetPath();
        int count = 0;
        while (getimage.moveToNext()){
            Bitmap bm = BitmapFactory.decodeFile(getimage.getString(0));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            bm.compress(Bitmap.CompressFormat.JPEG, 35, out);
            imageid = arabic.getText().toString()+"-"+System.currentTimeMillis()+"_"+(count++)+"."+getExtension(uri);
            System.out.println("IMAGES UPLOADEDDDD: "+ imageid);
            String id = getIntent().getStringExtra("storeid");
            member.setImageid(imageid);
            reference.child(id).child(arname).setValue(member);
            byte[] data = out.toByteArray();
            StorageReference Ref = mStorageRef.child(imageid);
            Ref.putBytes(data)
                    .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                            // Get a URL to the uploaded content
                            //Uri downloadUrl = taskSnapshot.getDownloadUrl();
                            //Toast.makeText(profuctadd.this,"Image uploaded",Toast.LENGTH_LONG).show();
                            progress.hideProgress();
                            Intent intent = new Intent(profuctadd.this,showProducts.class);
                            intent.putExtra("spec",getIntent().getStringExtra("spec"));
                            intent.putExtra("storeid",getIntent().getStringExtra("storeid"));
                            startActivity(intent);
                            DatabaseHelper mDatabaseHelper = new DatabaseHelper(profuctadd.this);
                            Cursor cursor2 = mDatabaseHelper.DeleteDataOfTableImagesAr();
                            cursor2.moveToNext();
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception exception) {
                            // Handle unsuccessful uploads
                            // ...
                            Toast.makeText(profuctadd.this,"Failed",Toast.LENGTH_LONG).show();
                        }
                    });

        }





    }

My firebase db:

Firebase Database

Hasnain Sabir :

you can save more than one image of specific user in images node like that.

DatabaseReference dr =  FirebaseDatabase.getInstance().getReference("tL131);

 dr.child("images").push().setValue(String.ValueOf(taskSnapshot.getDownloadUrl()));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get imageUrl from firebase storage to store in firebase realtime database?

How to get an object from Firebase Realtime Database?

Get information from Firebase Realtime Database with Firebase Admin SDK

Uploading multiple images to firebase storage and saving the download url to realtime database in android studio kotlin

How is storage size calculated in Firebase Realtime Database?

Firebase : Differences between realtime database and file storage

Firebase Storage or realtime Database for rarely updated files

How is firebase realtime database storage calculated

Upload image to firebase realtime Database or storage?

How do I get data from firebase realtime database in web?

Get parent nodes from Firebase realtime database event in flutter application

Android Studio - How to get value from FireBase Realtime Database

how to get string array from firebase realtime database

How to get Firebase Realtime Database reference from Unity Desktop build?

How to get data from Firebase Realtime Database and show it in a spinner?

How to get values from different child in firebase realtime database?

Dynamically get data from firebase realtime database during runtime in javascript

How to get the last data from realtime database of firebase in Android

How to get elements from a condition node in a Realtime Database Firebase

how to get and display data from firebase realtime database?

How can I get the latest record from Firebase Realtime Database

How to get single item from firebase realtime database?

How to get value from firebase realtime database in android?

Get data from google firebase realtime database web

How to get the data from firebase realtime database in react js?

How to get a specific value from firebase realtime database using kotlin

Firebase Realtime Database not displaying images in Recyclerview

Unsubscribing from Firebase Realtime Database

read from firebase realtime database