File

data class File(val source: String) : MediaContent(source)

Represents a document file that can be loaded from a local path. URLs are not supported for security reasons.

Constructors

Link copied to clipboard
constructor(source: String)

Properties

Link copied to clipboard
open override val format: String?

The file format/extension of the media content.

Link copied to clipboard

The local file path.

Functions

Link copied to clipboard

Gets the file name from the source path.

Link copied to clipboard
open override fun getMimeType(): String

Gets the MIME type based on the file format.

Link copied to clipboard
fun isUrl(): Boolean

Checks if the file source is a URL.

Link copied to clipboard

Reads the content of a file based on its source type. If the file source is a local path, the file content is read and returned as a string. If the file source is a URL, an error is thrown.

Link copied to clipboard
open override fun toBase64(): String

Converts the file content to a Base64 encoded string. This method supports encoding for files with a local path source. For URL sources, an exception is thrown since encoding is not supported directly.