Home How to upload Multiple Images to firebase and get the URL in separate childs just am getting all the URL in one child value
Reply: 0

How to upload Multiple Images to firebase and get the URL in separate childs just am getting all the URL in one child value

user3364 Published in March 19, 2018, 4:36 pm
public class MainActivity extends AppCompatActivity {

    String key;
    private ImageView mImageView;
    private FirebaseStorage mStorageRef;
    private Button mButton;
    private StorageTask mUploadTask;
    private List<Uri> uploadedImages = new ArrayList<>();

    private DatabaseReference mRefre;
    ArrayList<String> filepath = new ArrayList<>();

    protected void onCreate(Bundle savedInstanceState) {

        mImageView = (ImageView) findViewById(R.id.hhhh);

        mRefre = FirebaseDatabase.getInstance().getReference();
        mButton = (Button) findViewById(R.id.addphoto);

        mButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {



    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {

            case FilePickerConst.REQUEST_CODE:

                if (resultCode == RESULT_OK && data != null) {

                    final ArrayList<String> filepath;
                    filepath = data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_PHOTOS);


                    for (String path : filepath) {

                        final Uri file = Uri.fromFile(new File(path));
                        key = mRefre.child("products").push().getKey();

                        StorageReference photoRef = FirebaseStorage.getInstance().getReference("Images").child(uploadedImages + file.getLastPathSegment());

                        mUploadTask = photoRef.putFile(file);
                        mUploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

                                Uri downloadUrl = taskSnapshot.getDownloadUrl();

                                HashMap userMap = new HashMap();

I am doing firebase project and trying to upload multiple images using imagepicker with a maximum of 3 images. The images are successfully uploaded to firebase storage but when I try to get the URL it saves the 3 images in one child Value. I am trying to save it in separate values and name them so I can retrieve them later.

How can I fix this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.453495 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO