From c85c9d2adbe1d28dc948bd52445a6e9e0f057b53 Mon Sep 17 00:00:00 2001 From: Regis Leray Date: Fri, 27 Aug 2021 10:28:40 -0400 Subject: [PATCH] [247] fix putObject remove ByteBuffer wrap, use ByteArray (#251) --- src/main/scala/zio/s3/Live.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/scala/zio/s3/Live.scala b/src/main/scala/zio/s3/Live.scala index e97726c3..dd065fca 100644 --- a/src/main/scala/zio/s3/Live.scala +++ b/src/main/scala/zio/s3/Live.scala @@ -120,9 +120,11 @@ 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()) + .refineOrDie { + case e: S3Exception => e + } + .mapM { chunk => execute( _.putObject( { @@ -137,10 +139,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](