getFileContent

abstract suspend fun getFileContent(fileId: String): ByteArray

Retrieves the raw content of a file as a byte array.

Warning: Loading large files directly into memory can cause an OutOfMemoryError. To stream large files safely, use streamFileContent or for download content to file use downloadFileContentTo.

Return

The file content.

Parameters

fileId

The ID of the file.

Samples

// Please be careful!
// This function may cause an **OutOfMemoryError** if the file is too large.

val bytes = client.getFileContent("file_id")

// For example: Write bytes to file.
KoryFile.create("file.ext") { file ->
    file.writeBytes(bytes)
}