From aee78a4bc343785977503e933d30e732a93afa41 Mon Sep 17 00:00:00 2001 From: regis-leray Date: Fri, 27 Aug 2021 09:25:18 -0400 Subject: [PATCH] [247] fix putObject remove ByteBuffer wrap, use ByteArray --- src/main/scala/zio/s3/Live.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/zio/s3/Live.scala b/src/main/scala/zio/s3/Live.scala index e97726c3..9fb556ff 100644 --- a/src/main/scala/zio/s3/Live.scala +++ b/src/main/scala/zio/s3/Live.scala @@ -120,9 +120,8 @@ final class Live(unsafeClient: S3AsyncClient) extends S3.Service { ): ZIO[R, S3Exception, Unit] = content .mapChunks(Chunk.single) - .map(c => ByteBuffer.wrap(c.toArray)) - .toPublisher - .flatMap(publisher => + .mapError(e => S3Exception.builder().message(e.getMessage).cause(e).build()) + .mapM { chunk => execute( _.putObject( { @@ -137,10 +136,11 @@ final class Live(unsafeClient: S3AsyncClient) extends S3.Service { .fold(builder)(builder.contentType) .build() }, - AsyncRequestBody.fromPublisher(publisher) + AsyncRequestBody.fromBytes(chunk.toArray) ) ) - ) + } + .runCollect .unit def multipartUpload[R](