GoogleDriveStorage

class GoogleDriveStorage(context: ERROR CLASS: Symbol not found for Context, tokenProvider: DriveTokenProvider = PlayServicesTokenProvider(context), httpClient: HttpClient = BackupKitHttp.default()) : CloudStorage(source)

Google Drive app-data transport. Flat folder; paths are used verbatim as Drive file names. Uploads up to 5 MB go multipart in one request; larger ones use Drive's resumable protocol in 8 MiB chunks, streamed from disk for local files. list also removes duplicate files left by interrupted creates, keeping the newest by modified time.

Constructors

Link copied to clipboard
constructor(context: ERROR CLASS: Symbol not found for Context, tokenProvider: DriveTokenProvider = PlayServicesTokenProvider(context), httpClient: HttpClient = BackupKitHttp.default())

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?

No account is read; a sync engine keys identity off the marker file's Drive id instead.

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

Every file, deduplicated by path (newest wins).

Link copied to clipboard
open suspend 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.