Bytes

data class Bytes(val bytes: ByteArray, val mimeType: MimeType = MimeType.Image.Jpeg) : ImageSource

An image stored as raw bytes with a MIME type.

Samples

val imageBytes = try {
    // Read bytes from file(example)
    readBytes("path/to/photo.jpg")
} catch (fNEx: FileNotFoundException) {
    println("Image not found, detail message: ${fNEx.message}")
    null
} catch (e: Exception) {
    println("Error on reading image bytes: ${e.message}")
    null
}

imageBytes?.let { bytes ->
    val source = ImageSource.Bytes(
        bytes = bytes
    )

    // Add image Source to content and send to API...
}

Constructors

Link copied to clipboard
constructor(bytes: ByteArray, mimeType: MimeType = MimeType.Image.Jpeg)

Properties

Link copied to clipboard

The raw image bytes.

Link copied to clipboard

The MIME type (default: "image/jpeg").

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Serializes this ImageSource to a string representation.