Get picasso image based on userId firebase

I am trying to upload and upload an image for a user profile when I save a photo. I save it with userId, so I can replace it every time it changes its photo. Now I need to get this photo using picasso, the fact is that I don’t know how to get the photo, it can have different formats and other things like jpeg, png, I just want to get the image when the user ID matches, I tried this:

storageRef = storage.getReferenceFromUrl("gs://friendlymanager-3b7a2.appspot.com");

Picasso.with(UserSettings.this).load(storageRef + "/Photos/" + userId).into(userImage);

my userImage is my image, I do not receive any erros just a blank image, I already have a photo for a specific user.

Any help?

+4
source share
3 answers

Consider using the Android Firebase-UI library , which gives you the ability to directly download images from the ref store. In your case, it will look something like this.

I'm not sure if Picasso is supported, but you can use Glide  for example:

mStorageRef = FirebaseStorage.getInstance().getReference();

Glide.with(this /* context */)
    .using(new FirebaseImageLoader())
    .load(mStorageRef + "/Photos/" + userId)
    .error(R.drawable.default)
    .into(imageView);
+2
source

You must use getDownloadUrl()when retrieving images from Firebase storage using Picasso sliding slide OR, etc.

+2
source

you will need to get a download link, for example,

 StorageReference storageRef = storage.getReference().child("users").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(FirebaseAuth.getInstance().getCurrentUser().getUid());//reach out to your photo file hierarchically as stored  on firebase
            storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                @Override
                public void onSuccess(Uri uri) {
                    Log.e("URI", uri.toString());
                    Glide.with(SaveUserActivity.this).load(uri).into(profile_image);
                    url = uri.toString();

                }
            });
+2
source

Source: https://habr.com/ru/post/1674738/


All Articles