ICloudStorage

class ICloudStorage(folder: String = "backupkit", containerIdentifier: String? = null, downloadTimeout: Duration = 30.seconds) : CloudStorage(source)

iCloud Drive transport: plain files under <ubiquity container>/<folder>/, OUTSIDE Documents/, so they stay private to the app and invisible in Files. Writes land locally through NSFileCoordinator and the iCloud daemon uploads on its own. Reads force a download and wait with a bounded poll (a not-yet-downloaded file is never coordinated directly: that blocks).

Requires the iCloud Documents capability and a ubiquity container in the app's entitlements (see docs/setup-ios.md). containerIdentifier null means the first container listed there.

Constructors

Link copied to clipboard
constructor(folder: String = "backupkit", containerIdentifier: String? = null, downloadTimeout: Duration = 30.seconds)

Properties

Link copied to clipboard
open override val provider: CloudProvider

Functions

Link copied to clipboard
open suspend override fun availability(): CloudAvailability

Cheap. Never touches the network.

Link copied to clipboard
open suspend override fun delete(path: String, remoteId: String?)

No-op when already absent.

Link copied to clipboard
open suspend override fun downloadFile(path: String, toLocalPath: String, remoteId: String?)

Downloads into toLocalPath, replacing it. Throws CloudError.NotFound when absent.

Link copied to clipboard
open suspend override fun exists(path: String): Boolean
Link copied to clipboard
open suspend override fun identityKey(): String?

Apple's documented way to compare the token across launches is to ARCHIVE it. Its description may carry a per-process pointer, which would look like a new account on every start and force a full re-upload.

Link copied to clipboard
open suspend override fun list(): List<RemoteFile>

Every file, deduplicated by path (newest wins).

Link copied to clipboard
open suspend override fun prefetch(paths: List<String>)

Starts downloading every not-yet-local file in paths at once, without waiting. iCloud only; Drive has nothing to prefetch. Never throws. Call it before a restore so files download in parallel instead of one at a time.

Link copied to clipboard
open suspend override fun readBytes(path: String, remoteId: String?): ByteArray?

Whole contents, or null when absent. Forces an iCloud download first.

Link copied to clipboard
open suspend override fun writeBytes(path: String, bytes: ByteArray, mimeType: String, existingRemoteId: String?): String?

Create or replace from memory. Returns the remote id on Drive, null on iCloud.

Link copied to clipboard
open suspend override fun writeFile(path: String, localPath: String, mimeType: String, existingRemoteId: String?): String?

Create or replace from a local file. Returns the remote id on Drive, null on iCloud.