Firebase Storage Downloads Doesn't Resume on Network Reconnection

风流意气都作罢 提交于 2019-12-13 04:13:36

问题


The Story

I am using Firebase Storage to upload and download files. The upload works almost perfectly and if the device looses internet connection for a few minutes, then the upload stops, but it automatically resumes once the connection is back.

The Problem

I was expecting this exact same behaviour for the downloads as well. But it doesn't work like that. If my device looses internet connection, the downloads fails abruptly and doesn't automatically once the connection is back after a few seconds.

Is this the normal behaviour or am I missing something?

EDIT

This is the error,

com.google.firebase.storage.StorageException: An unknown error occurred, please check the HTTP result code and inner exception for server response.

Read error: ssl=0xb7e7a510: I/O error during system call, Connection timed out
                                                                           javax.net.ssl.SSLException: Read error: ssl=0xb7e7a510: I/O error during system call, Connection timed out
                                                                               at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
                                                                               at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:699)
                                                                               at com.android.okio.Okio$2.read(Okio.java:113)
                                                                               at com.android.okio.RealBufferedSource.read(RealBufferedSource.java:48)
                                                                               at com.android.okhttp.internal.http.HttpConnection$FixedLengthSource.read(HttpConnection.java:446)
                                                                               at com.android.okio.RealBufferedSource$1.read(RealBufferedSource.java:168)
                                                                               at java.io.InputStream.read(InputStream.java:162)
                                                                               at com.google.firebase.storage.FileDownloadTask.run(Unknown Source)
                                                                               at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
                                                                               at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                               at java.lang.Thread.run(Thread.java:818)

回答1:


You can manage robust downloads using the Android Download manager with the download url (reference.getDownloadUrl()).

See: Android download manager completed

We'll improve this handling in an upcoming release. Also I recommend using the many image download SDKs (like Glide https://github.com/bumptech/glide)



来源:https://stackoverflow.com/questions/38993429/firebase-storage-downloads-doesnt-resume-on-network-reconnection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!