颤音:当我想从firebase存储中显示图像时,它不起作用

发布于 2025-02-06 05:27:14 字数 3021 浏览 2 评论 0原文

这就是它在终端中得到的。

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;
  }

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴者 2025-02-13 05:27:14

在代码和存储中使用扩展名更正文件名。请检查存储安全规则以获取阅读许可。

Correct the file name with extension both in code and storage. Please check the storage security rule for reading permission.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文