Skip to main content

Autoupload Folders

This guide describes the mechanism of startup folders - buckets. The bucket mechanism provides features such as control of inclusion, as well as tracking the status of buckets.

The list of buckets containing photo / video files is built automatically when scanning the local gallery (see Reading photos from the local gallery) and is stored in the local Photos SDK database.

Bucket Inclusion Control#

The library provides the following methods to enable and disable buckets, in order to stop or resume loading from them.

important
  • When you enable a folder, photos / videos will be displayed in the timeline and uploaded to the cloud.

  • If you disable a folder, photos / videos that have not yet started uploading to the cloud will not be uploaded. Such photos / videos will not be displayed in the timeline.

Set Bucket Enabled#

Sample code of enabling/disabling a bucket:

var disposable: Disposable? = null
val bucketId: String = "Some_id"
val enabled: Boolean = true
// ...
// Returns completable, which completes when the data is updated to the database.// You have to subscribe on returned observable in order to receive updates.disposable = PhotoManager.timeline.setBucketEnabled(bucketId, enabled)        .subscribeOn(Schedulers.io())        .observeOn(AndroidSchedulers.mainThread())        .subscribeBy(                onComplete = {                    // do something...                },                onError = { // it: Throwable                    // do something...                }        )
// ...
// You must call dispose() on disposable that returned by subscribe() method,// when it no longer needed, for example in your fragment’s onStop() or onPause().disposable?.dispose()

Set Buckets Enabled#

Sample code of enabling buckets:

var disposable: Disposable? = null
val bucketIdList: List<String>
val enabled: Boolean = true
// ...
// Returns completable, which completes when the data is updated to the database.// You have to subscribe on returned observable in order to receive updates.disposable = PhotoManager.timeline.setBucketsEnabled(bucketIdList, enabled)        .subscribeOn(Schedulers.io())        .observeOn(AndroidSchedulers.mainThread())        .subscribeBy(                onComplete = {                    // do something...                },                onError = { // it -> Throwable                    // do something...                }        )
// ...
// You must call dispose() on disposable that returned by subscribe() method,// when it no longer needed, for example in your fragment’s onStop() or onPause().disposable?.dispose()

Set All Buckets Enabled#

For user convenience, applications can provide the ability to enable or disable all folders at once (for example, the user disables all folders, and then enables only some of them). Since the operation on a folder is performed in the background and may take some time, consecutive disconnection of all folders one by one (for example, in a loop) is ineffective. For such cases, it is recommended to use the PhotoManager.timeline.setAllBucketsEnabled(enable) function.

Sample code of enabling a bucket:

var disposable: Disposable? = null
val enabled: Boolean = true
// ...
// Returns completable, which completes when the data is updated to the database.// You have to subscribe on returned observable in order to receive updates.disposable = PhotoManager.timeline.setAllBucketEnabled(enabled)        .subscribeOn(Schedulers.io())        .observeOn(AndroidSchedulers.mainThread())        .subscribeBy(                onComplete = {                    // do something...                },                onError = { // it: Throwable                    // do something...                }        )
// ...
// You must call dispose() on disposable that returned by subscribe() method,// when it no longer needed, for example in your fragment’s onStop() or onPause().disposable?.dispose()

Bucket Tracking#

You can use the following method to track changes in bucket states:

var disposable: Disposable? = null
// ...
// Returns observable, which emits list of buckets when some bucket changes state.// You have to subscribe on returned observable in order to receive updates.disposable = PhotoManager.timeline.getBucketListObservable()        .observeOn(AndroidSchedulers.mainThread())        .subscribeBy(                onNext = { // it: List<BucketItem>!                    // do something...                },                onError = { // it: Throwable                    // do something...                }        )
// ...
// You must call dispose() on disposable that returned by subscribe() method,// when it no longer needed, for example in your fragment’s onStop() or onPause().disposable?.dispose()