[reactives3client] add console logging

This commit is contained in:
Paul Campbell 2019-05-09 18:46:25 +01:00
parent e43b7dc0e3
commit 232ea40be6

View file

@ -3,6 +3,7 @@ package net.kemitix.s3thorp.awssdk
import cats.effect.IO
import com.github.j5ik2o.reactive.aws.s3.S3AsyncClient
import com.github.j5ik2o.reactive.aws.s3.cats.S3CatsIOClient
import net.kemitix.s3thorp.Main.putStrLn
import net.kemitix.s3thorp.Sync.{Bucket, LocalFile, RemoteKey}
import software.amazon.awssdk.core.async.AsyncRequestBody
import software.amazon.awssdk.services.s3.model.{HeadObjectRequest, NoSuchKeyException, PutObjectRequest}
@ -19,7 +20,9 @@ private class ReactiveS3Client extends S3Client {
.build()
try {
for {
_ <- putStrLn(s"S3:HeadObject: $bucket : $remoteKey")
response <- s3Client.headObject(request)
_ <- putStrLn(s" -- ${response.eTag()} : ${response.lastModified()}")
} yield Some((response.eTag(), response.lastModified()))
} catch {
case _: NoSuchKeyException => IO(None)
@ -34,7 +37,9 @@ private class ReactiveS3Client extends S3Client {
val body = AsyncRequestBody.fromFile(localFile)
try {
for {
_ <- putStrLn(s"S3:PutObject: $bucket : $remoteKey")
_ <- s3Client.putObject(request, body)
_ <- putStrLn(" -- Done")
} yield ()
}
}