Ama*_*mal 7 android firebase firebase-storage
我想在imageView中显示图像,这就是我正在做的事情:我正在使用FirebaseUI来显示来自FireBase Storage的图像.
FirebaseStorage storageDisplayImg;
StorageReference storageRef;
private FirebaseAuth auth;
storageDisplayImg=FirebaseStorage.getInstance();
auth = FirebaseAuth.getInstance();
FirebaseUser userConnect = auth.getCurrentUser();
String id_user=userConnect.getUid();
storageRef = storageDisplayImg.getReference().child(item.getChemin_image()); // return gs://mydreambook-32321.appspot.com/images/test23-03-2017_16:46:55
if (item.getChemin_image() != null&&id_user != null) {
Glide.with(convertView.getContext() )
.using(new FirebaseImageLoader())
.load(storageRef)
.into(profilePic);
profilePic.setVisibility(View.VISIBLE);
} else {
profilePic.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)
但我有这个错误:
StorageException has occurred. Object does not exist at location. Code: -13010 HttpResult: 404
Run Code Online (Sandbox Code Playgroud)
更新,存储FireBase中的图像
您可以使用 Glide 方法以两种方式简单地显示图像。如果我们想访问下面的方法,我们必须更改Firebase存储规则。在这里我包括了我的规则。
service firebase.storage {
match /b/project-id.appspot.com/o {
match /{allPaths=**} {
allow write: if request.auth != null;
// or allow write: if true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
方法 1. 只需使用 Firebase 参考
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://your-id.appspot.com");
StorageReference pathReference = storageRef.child("images/cross.png");
Glide.with(context)
.using(new FirebaseImageLoader())
.load(pathReference)
.into(Imageview)
Run Code Online (Sandbox Code Playgroud)
方法 2.Firebase URL
Glide.with(context)
.using(new FirebaseImageLoader())
.load("Firebase_ImageURL")
.into(Imageview)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7753 次 |
最近记录: |