Skip to content

Commit

Permalink
[247] fix putObject remove ByteBuffer wrap, use ByteArray
Browse files Browse the repository at this point in the history
  • Loading branch information
regis-leray committed Aug 27, 2021
1 parent 4d7ce6e commit ddbf359
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/scala/zio/s3/Live.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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](
Expand Down

0 comments on commit ddbf359

Please sign in to comment.