uploadBytes

fun S3AsyncClient.uploadBytes(upstream: Flow<Byte>, concurrency: Int = 1, initialRequest: CreateMultipartUploadRequest.Builder.() -> Unit): Flow<S3Response>

Creates a flow that uploads bytes 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: S3AsyncClient = ...
val bucket = "my-bucket"
val key = "path/to/myfile.txt"
val byteFlow = flowOf<Byte> { ... } // A Flow<Byte> containing the bytes to upload.

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

Parameters

upstream

A Flow of bytes to upload.

concurrency

The level of concurrency for uploading bytes.

initialRequest

A builder function for the initial multipart upload request.


fun S3AsyncClient.uploadBytes(bucket: String, key: String, upstream: Flow<Byte>, concurrency: Int = 1): Flow<S3Response>

Creates a flow that uploads bytes 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: S3AsyncClient = ...
val bucket = "my-bucket"
val key = "path/to/myfile.txt"
val byteFlow = flowOf<Byte> { ... } // A Flow<Byte> containing the bytes to upload.

s3Client.uploadBytes(bucket, key, byteFlow)
.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 bytes to upload.

concurrency

The level of concurrency for uploading bytes.