mergeContents

fun S3AsyncClient.mergeContents(bucket: String, key: String, concurrency: Int = 1, files: List<Pair<String, String>>): Flow<S3Response>

This function performs a merge by using multipart upload copy operations using the S3AsyncClient. It copies multiple source files into a single destination object in an S3 bucket.

Return

A flow of S3Response objects for each part of the multipart copy operation.

Example usage:

val s3Client = S3AsyncClient.create()
val bucket = "my-bucket"
val destinationKey = "merged-file.txt"

val sourceFiles = flowOf(
"source-bucket-1" to "file1.txt",
"source-bucket-2" to "file2.txt",
"source-bucket-3" to "file3.txt"
)

s3Client.multipartUploadCopy(
bucket = bucket,
key = destinationKey,
concurrency = 2,
files = sourceFiles
).collect { response ->
println("Copied part: ${response.key}")
}

Parameters

bucket

The S3 bucket where the destination object will be stored.

key

The key of the destination object in the S3 bucket.

concurrency

The number of concurrent copy operations to perform. Default is 1.

files

A flow of source file pairs, where the first element is the source bucket and the second element is the source key.