I've send a imageUri to the final acivity and show it on my imageview, and when i want to upload the image to storage, its show me content://media/ext

0

Issue

I’ve send a imageUri to the final acivity and show it on my imageview, and when i want to upload the image to storage, its show me content://media/external/images/media/9863" that’s look like this

how can i send the image to firebase storage and get the imageUri, because when i try this, they say can’t complete cause of the string type

enter image description here

the imageUri was the string that i’ve send to my final activity, and when i show it to the imageView, the picture showup, but when i get the data from imageview they give me local storage location instead of download url

i’ve read this How to get the download url from Firebase Storage? but this is for getting the download url from firebase storage. i want to get the bitmap and upload it first to my storage firebase

Solution

oh im using this as the answer of the top question

 private void uploadToFirebase(Uri uri) {
        StorageReference fileRef = ref.child (System.currentTimeMillis () + "." + getFileExtension(uri));
        fileRef.putFile (uri).addOnSuccessListener (new OnSuccessListener<UploadTask.TaskSnapshot> ( ) {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                fileRef.getDownloadUrl ().addOnSuccessListener (new OnSuccessListener<Uri> ( ) {
                    @Override
                    public void onSuccess(Uri uri) {

                        Model model = new Model ( uri.toString () );
                        root.child(currentDateandTime).child("GambarDokumen").child("KTP").setValue(model);
                        finish();
                    }
                });
            }
        }).addOnProgressListener (new OnProgressListener<UploadTask.TaskSnapshot> ( ) {
            @Override
            public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
            }
        }).addOnFailureListener (new OnFailureListener ( ) {
            @Override
            public void onFailure(@NonNull Exception e) {

            }
        });

    }

and its work properly/how the way i want now

Answered By – Royal Agent

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More