无法从Firebase上的存储参考获取URI [英] Unable to get URI from storage reference on Firebase
本文介绍了无法从Firebase上的存储参考获取URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取存储在Firebase存储中的图像URI,以便使用其他方法进行处理.我正在使用以下内容:
I'm trying to get an image URI that is stored in Firebase storage, in order to process it using another method. I'm using the following:
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(this.getString(R.string.storage_path));
Uri uri = storageRef.child("groups/pizza.png").getDownloadUrl().getResult();
并收到错误消息"java.lang.IllegalStateException:任务尚未完成"
and getting an error "java.lang.IllegalStateException: Task is not yet complete"
推荐答案
您可以通过以下方式获取文件的下载URL:
You can get the download URL for a file with:
storageRef.child("groups/pizza.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// TODO: handle uri
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
有关通过URL下载数据的信息,请参见 Firebase文档
See the Firebase documentation for downloading data via a URL.
这篇关于无法从Firebase上的存储参考获取URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文