[Reactives3client] use S3CatsIOClient

This commit is contained in:
Paul Campbell 2019-05-08 10:02:12 +01:00
parent f099765dd3
commit 837ab362c3

View file

@ -1,20 +1,20 @@
package net.kemitix.s3thorp
import cats.effect.IO
import com.github.j5ik2o.reactive.aws.s3.S3AsyncClient
import com.github.j5ik2o.reactive.aws.s3.cats.S3CatsIOClient
import software.amazon.awssdk.services.s3.model.HeadObjectRequest
import software.amazon.awssdk.services.s3.{S3AsyncClient => JavaS3AsyncClient}
class ReactiveS3Client extends S3Client {
val s3Client = S3AsyncClient(JavaS3AsyncClient.create())
private val s3Client = S3CatsIOClient(S3AsyncClient(JavaS3AsyncClient.create))
override def objectHead(bucket: String, key: String) = {
IO.fromFuture(IO(
s3Client.headObject(HeadObjectRequest.builder()
.bucket(bucket)
.key(key)
.build()))).
val request = HeadObjectRequest.builder()
.bucket(bucket)
.key(key)
.build()
s3Client.headObject(request).
map(r => (r.eTag(), r.lastModified()))
}
}