MPBackupExporter

Entity able to serialize BackupData entities, like BackupMessage, BackupConversation, BackupUser into a cross-platform BackupData format.

Entity able to serialize BackupData entities, like BackupMessage, BackupConversation, BackupUser into a cross-platform BackupData format.

Samples

import com.wire.backup.dump.MPBackupExporter
import com.wire.backup.ingest.BackupPeekResult
import com.wire.backup.ingest.MPBackupImporter
import com.wire.backup.ingest.isCreatedBySameUser
import kotlinx.coroutines.await
import org.khronos.webgl.Uint8Array
fun main() { 
   //sampleStart 
   val backupPassword = "Aqa123456!"
// Create a MPBackupExporter
val mpBackupExporter = MPBackupExporter(
    selfUserId = getSelfUserId(),
)

// Each client (iOS, Web, Android) has their own logic for fetching stuff from database
// It's probably necessary to paginate the data from database, in case there are tens of thousands of messages, for example
getMessagesFromDatabase().forEach { message ->
    mpBackupExporter.add(message)
}

getUsersFromDatabase().forEach { user ->
    mpBackupExporter.add(user)
}

getConversationsFromDatabase().forEach { conversation ->
    mpBackupExporter.add(conversation)
}

// When all data is exported, you can call finalize, getting the binary data of the file in a Promise
val fileData = mpBackupExporter.finalize(backupPassword).await() // Equivalent to await mpBackupExporter.finalize(...)
println("Backup created file. Raw binary data: $fileData") 
   //sampleEnd
}

Entity able to serialize BackupData entities, like BackupMessage, BackupConversation, BackupUser into a cross-platform BackupData format.

Samples

import com.wire.backup.dump.MPBackupExporter
import com.wire.backup.ingest.BackupPeekResult
import com.wire.backup.ingest.MPBackupImporter
import com.wire.backup.ingest.isCreatedBySameUser
fun main() { 
   //sampleStart 
   val backupPassword = "Aqa123456!"
// Create a MPBackupExporter
val mpBackupExporter = MPBackupExporter(
    selfUserId = getSelfUserId(),
    workDirectory = "/path/to/working/directory/",
    outputDirectory = "/path/to/output/directory/",
    fileZipper = { entries ->
        TODO("Zip all entries into a single zip file and return the path to this file")
    }
)

// Each client (iOS, Web, Android) has their own logic for fetching stuff from database
// It's probably necessary to paginate the data from database, in case there are tens of thousands of messages, for example
getMessagesFromDatabase().forEach { message ->
    mpBackupExporter.add(message)
}

getUsersFromDatabase().forEach { user ->
    mpBackupExporter.add(user)
}

getConversationsFromDatabase().forEach { conversation ->
    mpBackupExporter.add(conversation)
}

// When all data is exported, you can call finalize, saving the result into a file.
val pathToBackupFile = mpBackupExporter.finalize(backupPassword)
println("Backup created at $pathToBackupFile") 
   //sampleEnd
}

Constructors

Link copied to clipboard
constructor(selfUserId: BackupQualifiedId)
constructor(selfUserId: BackupQualifiedId, workDirectory: String, outputDirectory: String, fileZipper: FileZipper)

Properties

Link copied to clipboard
internal abstract val storage: BackupPageStorage
internal open override val storage: BackupPageStorage
internal open override val storage: BackupPageStorage

Functions

Link copied to clipboard
fun add(conversation: BackupConversation)
fun add(message: BackupMessage)
fun add(user: BackupUser)
fun add(conversation: BackupConversation)
fun add(message: BackupMessage)
fun add(user: BackupUser)
fun add(conversation: BackupConversation)
fun add(message: BackupMessage)
fun add(user: BackupUser)
Link copied to clipboard
internal suspend fun finalize(password: String?, output: <Error class: unknown class>): ExportResult
internal suspend fun finalize(password: String?, output: <Error class: unknown class>): ExportResult
fun finalize(password: String?): <Error class: unknown class><BackupExportResult>
internal suspend fun finalize(password: String?, output: <Error class: unknown class>): ExportResult
suspend fun finalize(password: String?): BackupExportResult
Link copied to clipboard
internal abstract fun zipEntries(data: List<BackupPage>): <Error class: unknown class><<Error class: unknown class>>
internal open override fun zipEntries(data: List<BackupPage>): <Error class: unknown class><<Error class: unknown class>>
internal open override fun zipEntries(data: List<BackupPage>): <Error class: unknown class><<Error class: unknown class>>