ChunkedFileOutputStream

class ChunkedFileOutputStream(val filesDir: File, chunkSize: Int, chunkNameGenerator: (Int) -> String = { id -> "chunk_$id" }, listener: ChunkedFileOutputStream.Listener = object : Listener {}) : OutputStream

A class that allows to write into multiple files. It is useful when you want to upload a file to a server but you don't want to wait for the record to finish before. Use this class as an OutputStream of a IFileStreamer.

Parameters

filesDir

the directory where the files will be written

chunkSize

the size of each file in bytes

chunkNameGenerator

generate the name of each file from its index

listener

the listener that will be called when a file is created

Constructors

Link copied to clipboard
constructor(filesDir: File, chunkSize: Int, chunkNameGenerator: (Int) -> String = { id -> "chunk_$id" }, listener: ChunkedFileOutputStream.Listener = object : Listener {})

Types

Link copied to clipboard
interface Listener

Properties

Link copied to clipboard
Link copied to clipboard

Get if the stream is closed.

Link copied to clipboard

Get the number of files written.

Functions

Link copied to clipboard
open override fun close()

Close the stream. This will close the current file and call Listener.onFileClosed with the last file.

Link copied to clipboard
open override fun flush()
Link copied to clipboard
open override fun write(b: ByteArray)

Write b to the stream.

open override fun write(i: Int)

Write i to the stream.

open override fun write(b: ByteArray, offset: Int, len: Int)

Write len bytes from b starting at offset.