颤音:当我想从firebase存储中显示图像时,它不起作用
这就是它在终端中得到的。
E/StorageException( 1371): StorageException has occurred.
E/StorageException( 1371): Object does not exist at location.
E/StorageException( 1371): Code: -13010 HttpResult: 404
E/StorageException( 1371): { "error": { "code": 404, "message": "Not Found." }}
E/StorageException( 1371): java.io.IOException: { "error": { "code": 404, "message": "Not Found." }}
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:453)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:289)
E/StorageException( 1371): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:76)
E/StorageException( 1371): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:68)
E/StorageException( 1371): at com.google.firebase.storage.GetDownloadUrlTask.run(GetDownloadUrlTask.java:77)
E/StorageException( 1371): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/StorageException( 1371): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/StorageException( 1371): at java.lang.Thread.run(Thread.java:923)
I/flutter ( 1371): [firebase_storage/object-not-found] No object exists at the desired reference.
**我的代码显示图像: - **
FutureBuilder(
future: getUserImagePath(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return Image.network(
snapshot.data!,
fit: BoxFit.cover,
);
}
if (snapshot.hasError) {
print(snapshot.error);
}
return Container();
}),
Future<String> getUserImagePath() async {
final user = await FirebaseAuth.instance.currentUser;
String userEmail = user!.email.toString();
print(userEmail);
final userRef = await FirebaseStorage.instance.ref();
String urlPath = 'users/${userEmail}/userProfile.jpeg';
final userProfileUrl = await userRef.child(urlPath).getDownloadURL();
print(userProfileUrl);
return userProfileUrl;
}
This is what it getting in the terminal.
E/StorageException( 1371): StorageException has occurred.
E/StorageException( 1371): Object does not exist at location.
E/StorageException( 1371): Code: -13010 HttpResult: 404
E/StorageException( 1371): { "error": { "code": 404, "message": "Not Found." }}
E/StorageException( 1371): java.io.IOException: { "error": { "code": 404, "message": "Not Found." }}
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:445)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:462)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:453)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
E/StorageException( 1371): at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:289)
E/StorageException( 1371): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:76)
E/StorageException( 1371): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:68)
E/StorageException( 1371): at com.google.firebase.storage.GetDownloadUrlTask.run(GetDownloadUrlTask.java:77)
E/StorageException( 1371): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/StorageException( 1371): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/StorageException( 1371): at java.lang.Thread.run(Thread.java:923)
I/flutter ( 1371): [firebase_storage/object-not-found] No object exists at the desired reference.
**My Code to display the image:- **
FutureBuilder(
future: getUserImagePath(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return Image.network(
snapshot.data!,
fit: BoxFit.cover,
);
}
if (snapshot.hasError) {
print(snapshot.error);
}
return Container();
}),
Future<String> getUserImagePath() async {
final user = await FirebaseAuth.instance.currentUser;
String userEmail = user!.email.toString();
print(userEmail);
final userRef = await FirebaseStorage.instance.ref();
String urlPath = 'users/${userEmail}/userProfile.jpeg';
final userProfileUrl = await userRef.child(urlPath).getDownloadURL();
print(userProfileUrl);
return userProfileUrl;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在代码和存储中使用扩展名更正文件名。请检查存储安全规则以获取阅读许可。
Correct the file name with extension both in code and storage. Please check the storage security rule for reading permission.