Firebase 存储在尝试上传图像时给出 StorageException [英] Firebase Storage is giving StorageException while trying to upload images

查看:27
本文介绍了Firebase 存储在尝试上传图像时给出 StorageException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将图像上传到新的 Firebase 存储服务.它正在抛出 StorageException

I have been trying to upload images to the new firebase storage service . It is throwing StorageException

E/StorageException:发生了 StorageException.发生未知错误,请检查HTTP结果代码和内部服务器响应的异常.代码:-13000 HttpResult:400

E/StorageException: StorageException has occurred. An unknown error occurred, please check the HTTP result code and inner exception for server response. Code: -13000 HttpResult: 400

E/StorageException: 服务器已终止上传会话java.io.IOException: 服务器已终止上传会话在 com.google.firebase.storage.UploadTask.zzVi(来源不明)在 com.google.firebase.storage.UploadTask.zzVh(来源不明)在 com.google.firebase.storage.UploadTask.run(未知来源)在 com.google.firebase.storage.StorageTask$5.run(来源不明)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)在java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)在 java.lang.Thread.run(Thread.java:818)

E/StorageException: The server has terminated the upload session java.io.IOException: The server has terminated the upload session at com.google.firebase.storage.UploadTask.zzVi(Unknown Source) at com.google.firebase.storage.UploadTask.zzVh(Unknown Source) at com.google.firebase.storage.UploadTask.run(Unknown Source) at com.google.firebase.storage.StorageTask$5.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

推荐答案

在google firebase 中,这种StorageException 常见的原因是由于错误StorageReference 参考.

In the google firebase this type of StorageException are commonly caused because of wrong StorageReference reference .

FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://<your-bucket-name>");

// Create a reference to "file"
StorageReference mountainsRef = storageRef.child("file.jpg");

确保对文件的引用正确无误.

Make sure the reference to the file is made correctly.

<小时>文档参考

可以在此处找到有关创建存储引用的详细信息

可以找到有关存储异常代码的详细信息在这里进一步参考

这篇关于Firebase 存储在尝试上传图像时给出 StorageException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆