@@ -14,13 +14,15 @@ import aws.smithy.kotlin.runtime.content.asByteStream
1414import aws.smithy.kotlin.runtime.content.decodeToString
1515import aws.smithy.kotlin.runtime.content.fromFile
1616import aws.smithy.kotlin.runtime.content.toByteArray
17+ import aws.smithy.kotlin.runtime.content.toByteStream
1718import aws.smithy.kotlin.runtime.hashing.sha256
1819import aws.smithy.kotlin.runtime.http.HttpException
1920import aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor
2021import aws.smithy.kotlin.runtime.http.request.HttpRequest
2122import aws.smithy.kotlin.runtime.testing.RandomTempFile
2223import aws.smithy.kotlin.runtime.text.encoding.encodeToHex
2324import kotlinx.coroutines.*
25+ import kotlinx.coroutines.flow.flow
2426import kotlinx.coroutines.flow.toList
2527import org.junit.jupiter.api.AfterAll
2628import org.junit.jupiter.api.BeforeAll
@@ -108,6 +110,20 @@ class S3BucketOpsIntegrationTest {
108110 assertEquals(contents, roundTrippedContents)
109111 }
110112
113+ @Test
114+ fun testPutObjectWithToByteStreamAndContentLength (): Unit = runBlocking {
115+ // See https://github.com/awslabs/aws-sdk-kotlin/issues/1249
116+ val keyName = " toByteStream-contentLength.txt"
117+ val arr = " Hello!" .encodeToByteArray()
118+
119+ client.putObject {
120+ bucket = testBucket
121+ key = keyName
122+ body = flow { emit(arr) }.toByteStream(this @runBlocking, arr.size.toLong())
123+ contentLength = arr.size.toLong()
124+ }
125+ }
126+
111127 @Test
112128 fun testGetEmptyObject (): Unit = runBlocking {
113129 // See https://github.com/awslabs/aws-sdk-kotlin/issues/1014
0 commit comments