Skip to content

Upload file to Firebase Storage and getDownloadurl()

Notifications You must be signed in to change notification settings

augustina55/firebaseupload

Repository files navigation

firebaseupload

Firebase image upload and get Download url

//Add this Code

      ref.putFile(filepath).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                //Image uploaded
                //GetdownloadURl here
                strg.child("Pic").getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
                    @Override
                    public void onComplete(@NonNull Task<Uri> task) {
                        //getdownloadUrl
                        downloadUrl=task.getResult().toString();
                        dbref.push().child("imageurl").setValue(downloadUrl);
                        progressDialog.dismiss();
                        Toast.makeText(MainActivity.this,"Image uploaded",Toast.LENGTH_LONG).show();
                    }
                });
            }
        });

Releases

No releases published

Packages

No packages published

Languages