I have a problem when I try to load an image located in Firebase Storage. In my Firebase project, I have storage an image called "profile.png" inside a folder called "imgProjects".
Searching in StackOverflow, I found some answers that indicates to use Glide for load the image into a "ImageView" element, but isn't working me...
In my activity, I tried:
FirebaseStorage storage2 = FirebaseStorage.getInstance("gs://myURLfirebaseProjecy/profile.png"); //I get this URL through firebase console
Glide.with(this)
.load(storage2)
.into(imgPerfil);
and
StorageReference storageRef = storage.getReference();
StorageReference imagesRef = storageRef.child("imgProjects\profile.png");
Glide.with(this)
.load(imagesRef)
.into(imgPerfil);
I defined "MyAppGlideModule" in a java file class
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
// Register FirebaseImageLoader to handle StorageReference
registry.append(StorageReference.class, InputStream.class,
new FirebaseImageLoader.Factory());
}
}
and I set the dependency:
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
implementation 'com.google.firebase:firebase-storage:16.0.5'
When I load the Activity, the ImageView it's empty... I need to use a "gs://" reference or an relative path.
Sorry but... What can I do to solve my issue??
you can get your image if you know what is the name of you image like this :-
StorageReference mImageStorage = FirebaseStorage.getInstance().getReference();
StorageReference ref = mImageStorage.child("storage name")
.child("your image name.jpg");
ref.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downUri = task.getResult();
String imageUrl = downUri.toString();
Toast.makeText(MainActivity.this, imageUrl , Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(MainActivity.this, ""+task.getException(), Toast.LENGTH_SHORT).show();
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.