Blob

expect class Blob(contentType: String, content: ByteArray)(source)

A Couchbase Lite Blob. A Blob appears as a property of a Document and contains arbitrary binary data, tagged with MIME type. Blobs can be arbitrarily large, although some operations may require that the entire content be loaded into memory. The containing document's JSON contains only the Blob's metadata (type, length and digest). The data itself is stored in a file whose name is the content digest (like git).

actual class Blob(contentType: String, content: ByteArray) : DelegatedClass<<Error class: unknown class>> (source)
actual class Blob(contentType: String, content: ByteArray)(source)

Constructors

Link copied to clipboard
expect constructor(contentType: String, stream: Source)

Construct a Blob with the given stream of data. The passed stream will be closed when it is copied either to memory (see getContent) or to the database. If it is closed before that, by client code, the attempt to store the blob will fail. The converse is also true: the stream for a blob that is not saved or copied to memory will not be closed (except during garbage collection).

expect constructor(contentType: String, fileURL: String)

Construct a Blob with the content of a file. The blob can then be added as a property of a Document. This constructor creates a stream that is not closed until the blob is stored in the db, or copied to memory (except by garbage collection).

expect constructor(contentType: String, content: ByteArray)
actual constructor(contentType: String, stream: Source)
actual constructor(contentType: String, fileURL: String)
actual constructor(contentType: String, content: ByteArray)
actual constructor(contentType: String, stream: Source)
actual constructor(contentType: String, fileURL: String)
actual constructor(contentType: String, content: ByteArray)

Types

Link copied to clipboard
expect object Companion
actual object Companion
actual object Companion

Properties

Link copied to clipboard
expect val content: ByteArray?

Gets the contents of this blob as an in-memory byte array. Using this method will cause the entire contents of the blob to be read into memory!

actual val content: ByteArray?
actual val content: ByteArray?
Link copied to clipboard
expect val contentStream: Source?

Get the contents of this blob as a stream. The caller is responsible for closing the stream returned by this call. Closing or deleting the database before this call completes may cause it to fail. When called on a blob created from a stream (or a file path), this method will return null!

actual val contentStream: Source?
actual val contentStream: Source?
Link copied to clipboard
expect val contentType: String

The type of the content this blob contains. By convention this is a MIME type.

actual val contentType: String
actual val contentType: String
Link copied to clipboard
expect val digest: String?

The cryptographic digest of this Blob's contents, which uniquely identifies it or null if the content has not been saved in a database

actual val digest: String?
actual val digest: String?
Link copied to clipboard
expect val length: Long

The number of bytes of content this blob contains or 0 if initialized with a stream.

actual val length: Long
actual val length: Long
Link copied to clipboard
expect val properties: Map<String, Any?>

The blob metadata

actual val properties: Map<String, Any?>
actual val properties: Map<String, Any?>

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
Link copied to clipboard
expect fun toJSON(): String
actual fun toJSON(): String
actual fun toJSON(): String
Link copied to clipboard
open override fun toString(): String
open override fun toString(): String