Firebase has great option of using their database and sending data to their db even if you are offline, and then when the connection is up again, it sends automatically the data to the db.
is it also possible to do it with the Firebase storage like send images even if the internet is off, and then when the internet is on again, it will send the images files automatically?
If so, how can I do it? If not with Firebase, any other option?
Yes. The Firebase Storage client supports resuming uploads. See the Firebase Storage documentation for uploads (iOS, Web, Android).
From there for Android:
uploadTask = mStorageRef.putFile(localFile);
sessionUri = uploadTask.getUploadSessionUri();
//save the sessionUri to persistent storage in case the process dies.
And then to resume:
//resume the upload task from where it left off when the process died.
//to do this, pass the sessionUri as the last parameter
uploadTask = mStorageRef.putFile(localFile,
new StorageMetadata.Builder().build(), sessionUri);
One way to handle the sessionUri:
uploadTask
, get the sessionUri
and store it to the app's SharedPreferences
.uploadTask
completes, remove the sessionUri from the app's SharedPreferences
.sessionUri
in the SharedPreferences
. If so: resume that upload.