mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Add underpinnings to allow for local plaintext export.
Co-authored-by: Cody Henthorne <cody@signal.org>
This commit is contained in:
committed by
Cody Henthorne
parent
b605148ac4
commit
f2e4881026
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.signal.archive.stream
|
||||
|
||||
import org.signal.archive.proto.BackupInfo
|
||||
import org.signal.archive.proto.Frame
|
||||
import org.signal.core.util.toJson
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
|
||||
/**
|
||||
* Writes backup frames to the wrapped stream as newline-delimited JSON (JSONL).
|
||||
*/
|
||||
class JsonBackupWriter(private val outputStream: OutputStream) : BackupExportWriter {
|
||||
|
||||
@Throws(IOException::class)
|
||||
override fun write(header: BackupInfo) {
|
||||
outputStream.write((header.toJson() + "\n").toByteArray())
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
override fun write(frame: Frame) {
|
||||
outputStream.write((frame.toJson() + "\n").toByteArray())
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
outputStream.close()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user