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
Functions
Finalize the export and write the data to the given output. This method should be called after all the data was added.
Finalize the export and write the data to the given output. This method should be called after all the data was added.
Exports all the previously added data to a BackupExportResult. This method should be called after all the data was added.
Finalize the export and write the data to the given output. This method should be called after all the data was added.
Persists all the data into a single backup file, returning a BackupExportResult. This method should be called after all the data was added.