PrivMX DOCS
Kotlin

Downloading Files

Downloading file content and accessing files.

The sample code on this page is based on the initial assumptions.

Downloading a file from the Store and saving it by chunk to ByteArray:

val fileID = "FILE_ID"
var data = ByteArray(0)

val closedFileID = StoreFileStreamReader.openFile(
    storeApi,
    fileID,
).also {
    do {
        val chunk = it.read(StoreFileStream.OPTIMAL_SEND_SIZE)
        data += chunk
    } while (chunk.size.toLong() == StoreFileStream.OPTIMAL_SEND_SIZE)
}.close()

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.

PrivMX Endpoint Kotlin v2.2

This package is not up to date with the core documentation. Some of the features you've seen described in other parts of the documentation might not be mentioned here. Those changes do not influence compatibility, however