Firebase存储同步上传 [英] Firebase Storage upload synchronously

查看:56
本文介绍了Firebase存储同步上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在GcmTaskService内上传到Firebase存储.我想同步进行上传,但是所有上传方法(putBytes,putFile ...)都是异步的.

I am trying to make a upload to Firebase Storage inside a GcmTaskService. I want to make the upload synchronously but all uploads methods (putBytes, putFile...) are async.

我没有找到等待上传完成的任何方法.有什么办法可以同步上传吗?

I did not found any method to wait until the upload finishes. Is there any way to make the upload synchronously?

推荐答案

是的,如果您不在UI线程上,则可以使用该方法阻止直到任务完成

Yes there is, if you are not on the UI thread, you can block until the task completes by using the method

com.google.android.gms.tasks.Tasks.await(task);

com.google.android.gms.tasks.Tasks.await(task);

这篇关于Firebase存储同步上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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