download

fun <Error class: unknown class>.download(bucket: String, key: String): Flow<Pair<<Error class: unknown class>, 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:  S3Client = ...
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.


fun <Error class: unknown class>.download(builder: <Error class: unknown class>.() -> Unit): Flow<Pair<<Error class: unknown class>, Flow<ByteArray>>>

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

This function takes a builder function to create a GetObjectRequest 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:  S3Client = ...
val bucket = "my-bucket"
val key = "path/to/myfile.txt"

s3Client
.download {
bucket = "my-bucket"
key = "path/to/myfile.txt"
}
.collect { (response, contentFlow) ->
println("Got file with response: $response")
println("Downloading...")

contentFlow.collect { byteArray ->
// Process byteArray
}
}

Parameters

builder

The request builder function.