Skip to content

Commit

Permalink
Avoid allocating a vector if you can use the underlying chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed Dec 13, 2023
1 parent 4324f32 commit 5ae230f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs2-aws-s3/src/main/scala/fs2/aws/s3/S3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ object S3 {
def uploadFile(bucket: BucketName, key: FileKey, modifier: AwsRequestModifier.Upload1): Pipe[F, Byte, ETag] =
in =>
fs2.Stream.eval {
in.compile.toVector.flatMap { vs =>
val bs = ByteBuffer.wrap(vs.toArray)
in.compile.to(Chunk).flatMap { chunks =>
val bs = chunks.toByteBuffer
s3.putObject(
modifier.putObject(PutObjectRequest.builder().bucket(bucket.value).key(key.value)).build(),
AsyncRequestBody.fromByteBuffer(bs)
Expand Down

0 comments on commit 5ae230f

Please sign in to comment.