Firebase - uploading images when internet is offline -
firebase has great option of using database , sending data db if offline, , when connection again, sends automaticlly data db.
is possible firebase storage? send images if internet offline, , when internet on again, send images files automaticlly?
if so, how can it? if not firebase, other option?
thanks
yes. firebase storage client supports resuming uploads. see firebase storage documentation uploads (ios, web, android).
from there android:
uploadtask = mstorageref.putfile(localfile); sessionuri = uploadtask.getuploadsessionuri(); //save sessionuri persistent storage in case process dies.
and resume:
//resume upload task left off when process died. //to this, pass sessionuri last parameter uploadtask = mstorageref.putfile(localfile, new storagemetadata.builder().build(), sessionuri);
update (20160809)
one way handle sessionuri:
- when create
uploadtask
,sessionuri
, store app'ssharedpreferences
. - when
uploadtask
completes, remove sessionuri app'ssharedpreferences
. - when app restarts, check if there
sessionuri
insharedpreferences
. if so: resume upload.
Comments
Post a Comment