Skip to main content

Family Cloud

The family cloud is a shared storage for photos and videos among family members. This guide describes the functionality of Family Cloud.

Read Family From Cloud Storage

To get started with the family cloud, first of all get actual family and members information from the backend. Use the PhotoManager.familyManager.fetch() method to get the family cloud information. This is suspended function, so you can call it from a coroutine.

important

Since the download procedure takes some time (and, on the other hand, does not require permission from the user), it should be started as soon as the user is logged into the application.

Use the following code example.

// ...
photosScope.launch {
try {
photoManager.familyManager.fetch()
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not active.
// IllegalArgumentException Session error. Profile ID not found.
// UnauthorizedException Unauthorized access.
// IllegalStateException Forbidden access.
// IOException Other problems.
}
}
// ...

Get Information About The Current Family Cloud

After retrieving information about the family cloud from the backend, use the following code to retrieve the downloaded information about the family cloud.

// ...
photosScope.launch {
photoManager.familyManager.createFamilyFlow().collect { family ->
// if family is null, then there is no family
}
}
// ...

Links - Family.

Create Family Cloud

If you don't have a family cloud, you can create one using the following example. This is a suspended function, so you can call it from a coroutine.

// ...
val familyName = "familyName" // Family name. Maximum name length - 250 characters.
val isOpened = true // Family is opened, boolean. Default true.

photosScope.launch {
try {
photoManager.familyManager.createFamily(familyName, isOpened)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not active.
// IllegalArgumentException Illegal family name.
// UnauthorizedException Unauthorized access.
// IllegalStateException Forbidden access.
// UserMemberOfOtherFamilyException The user is already a family member.
// IOException Other problems.
}
}
// ...

Edit Family Cloud

To edit the family cloud, use the following example. This is a suspended function, so you can call it from a coroutine.

// ...
val familyId = "familyId" // Family identification
val familyName = "familyName" // Family name. Maximum name length - 250 characters.
val isOpened = true // Family is opened, boolean. Default true.

photosScope.launch {
try {
photoManager.familyManager.editFamily(familyId, familyName, isOpened)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not active.
// IllegalArgumentException Illegal family name.
// UnauthorizedException Unauthorized access.
// IllegalStateException Forbidden access.
// IOException Other problems.
}
}
// ...

Delete Family Cloud

To delete the family cloud, use the following example. This is a suspended function, so you can call it from a coroutine.

// ...
val familyId = "familyId" // Family identification

photosScope.launch {
try {
photoManager.familyManager.deleteFamily(familyId)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not active.
// UnauthorizedException Unauthorized access.
// IllegalStateException Forbidden access.
// IOException Other problems.
}
}
// ...

Work With Media

Copy To Family Cloud

To copy media to family cloud, use the following code example.

important

Can be called only on the personal timeline instance.

var disposable: Disposable? = null

var photoList: List<PhotoItem> = listOf()

// ...

// Can be called only on personal timeline instance.
disposable = photoManager.timline.copyToAnotherCloud(photoList).single.subscribeBy(
onSuccess = {
// Handle it
},
onError = {
// Handle it
}
)

// ...

// You must call dispose() on disposable that returned by subscribe() method,
// when it is no longer needed, for example in your fragment’s onStop() or onPause().
disposable?.dispose()

Link - OperationCopyToAnotherCloud.

Copy To Personal Cloud

To copy media to personal, use the following code example.

important

Can be called only on the family timeline instance.

var disposable: Disposable? = null

var photoList: List<PhotoList> = listOf()

// ...

// Can be called only on family timeline instance
disposable = photoManager.familyTimeline.copyToAnotherCloud(photoList).single.subscribeBy(
onSuccess = {
// Handle it
},
onError = {
// Handle it
}
)

// ...

// You must call dispose() on disposable that returned by subscribe() method,
// when it is no longer needed, for example in your fragment’s onStop() or onPause().
disposable?.dispose()

Link - OperationCopyToAnotherCloud.

Family Cloud Member Management

Get List of Family Members

To get a list of family cloud members, use the following example.

// ...
photosScope.launch {
photoManager.familyManager.createFamilyMembersFlow().collect { familyMember ->
// Handle it
}
}
// ...

Links - FamilyMember.

Invite Family Members

Invitation of users is performed through the web-frontend.

The Family object has the inviteHash field. A user who wants to join the family must use the web client by following the link:

<you-frontend>/invite?fchash=<invite-hash>

For example, for Cloudike, this link might look like the link below:

https://saas.cloudike.com/invite?fchash=txWRNGneQtyEBgmq

Use the following example to join the family cloud.

// ...
val inviteHash = "txWRNGneQtyEBgmq"
val memberName = "someMemberName"

photosScope.launch {
try {
photoManager.familyManager.joinFamily(inviteHash, memberName)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not active.
// IllegalArgumentException Bad invite hash.
// UnauthorizedException Unauthorized access.
// UserAlreadyMemberOfFamilyException When the user is already a member of a family.
// UserMemberOfOtherFamilyException When the user is a member of an other family.
// IOException Other problems.
}
}
// ...

To invite a user to the family cloud, You will need to provide the familyId and the email or phone number of the user you want to invite. Use the following example to invite a user to the family cloud.

// ...
val familyId = "familyId"
val emailOrPhone = "someEmailOrPhone"

photosScope.launch {
try {
photoManager.familyManager.inviteIntoFamily(familyId, emailOrPhone)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not initialized.
// UserAlreadyMemberOfFamilyException When the user is already a member of a family.
// IncorrectPhoneOrEmailException When the phone or email is not in the correct format.
// IllegalArgumentException Another argument problems.
// UnauthorizedException Unauthorized access.
// IllegalStateException Access was denied.
// IOException Another problems.
}
}
// ...

Links - FamilyMember.

Edit Family Members

The following method will allow you to change the name of a family cloud member.

// ...
val familyId = "familyId"
val memberId = "memberId"
// New family member name. Maximum name length - 250 characters.
val newMemberName = "newMemberName"

photosScope.launch {
try {
photoManager.familyManager.editFamilyMember(familyId, memberId, newMemberName)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException Session is not active.
// IllegalArgumentException Illegal family name.
// UnauthorizedException Forbidden access.
// IOException Other problems.
}
}
// ...

Links - FamilyMember.

Delete users from the family cloud

Use the following example to remove members from the family cloud.

important

Only the family owner can remove family members. The family owner cannot delete himself.

// ...
val familyId = "familyId"
val memberId = "memberId"

photosScope.launch {
try {
photoManager.familyManager.deleteFamilyMember(familyId, memberId)
} catch (t: Throwable) {
// Possible exceptions:
// SessionIsNotInitializedException When session is not active.
// UnauthorizedException Unauthorized access.
// IllegalStateException Forbidden access.
// DeletingOwnerNotAllowedException An attempt was made to remove the family owner.
// IOException Other problems.
}
}
// ...

Links - FamilyMember.