download

fun S3AsyncClient.download(bucket: String, key: String): Flow<Pair<GetObjectResponse, Flow<ByteArray>>>

Creates a flow that downloads a file from an Amazon S3 bucket.

This function takes a bucket and key and returns a Flow of pairs containing the GetObjectResponse and a flow of byte arrays.

Return

A Flow of pairs containing the GetObjectResponse and a flow of byte arrays.

Example usage:

val s3Client: S3AsyncClient = ...
val bucket = "my-bucket"
val key = "path/to/myfile.txt"

s3Client.download(bucket, key)
.collect { (response, contentFlow) ->
println("Downloaded file with response: $response")
contentFlow.collect { byteArray ->
// Process byteArray
}
}

Parameters

bucket

The name of the S3 bucket.

key

The key of the file to download.