upload

fun <Error class: unknown class>.upload(bucket: String, key: String, upstream: Flow<ByteArray>, concurrency: Int = 1): Flow<S3Response.MultipartResponse<*>>

Creates a flow that uploads byte arrays to an Amazon S3 bucket.

This function works under the assumption that the upstream size is unknown, so it always uses the multipart upload strategy, as a versatile, "one-size-fits-all" solution.

This function takes a bucket, key, and upstream flow of bytes and uploads them to the specified S3 bucket. The function processes bytes concurrently using concurrency.

Return

A Flow of S3Response objects.

Example usage:

val s3Client:  S3Client = ...
val bucket = "my-bucket"
val key = "path/to/myfile.txt"
val byteArrayFlow = flowOf<ByteArray> { ... } // A Flow<ByteArray> containing the byte arrays to upload.

s3Client.upload(bucket, key, byteArrayFlow)
.collect { response ->
println("Upload response: $response")
}

Parameters

bucket

The name of the S3 bucket.

key

The key of the file to upload.

upstream

A Flow of byte arrays to upload.

concurrency

The level of concurrency for uploading byte arrays.


fun <Error class: unknown class>.upload(upstream: Flow<ByteArray>, concurrency: Int = 1, initialRequest: <Error class: unknown class>.() -> Unit): Flow<S3Response.MultipartResponse<*>>

Creates a flow that uploads byte arrays to an Amazon S3 bucket.

This function works under the assumption that the upstream size is unknown, so it always uses the multipart upload strategy, as a versatile, "one-size-fits-all" solution.

This function takes a initialRequest for the initial multipart upload request. The function processes bytes concurrently using concurrency.

Return

A Flow of S3Response objects.

Example usage:

val s3Client:  S3Client = ...
val bucket = "my-bucket"
val key = "path/to/myfile.txt"
val byteArrayFlow = flowOf<ByteArray> { ... } // A Flow<ByteArray> containing the byte arrays to upload.

s3Client
.upload(byteArrayFlow) {
bucket(bucket)
key(key)
}
.collect { response ->
println("Upload response: $response")
}

Parameters

upstream

A Flow of byte arrays to upload.

concurrency

The level of concurrency for uploading byte arrays.

initialRequest

A builder function for the initial multipart upload request.