PrivMX DOCS
Java

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.

This is documentation for PrivMX v2.2, which is no longer actively maintained.

For up-to-date documentation, go to latest here