[reactives3client] remove logging
This commit is contained in:
parent
c93bebb1e5
commit
b61499ed8f
1 changed files with 5 additions and 21 deletions
|
@ -1,43 +1,27 @@
|
||||||
package net.kemitix.s3thorp.awssdk
|
package net.kemitix.s3thorp.awssdk
|
||||||
|
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
import net.kemitix.s3thorp.Main.putStrLn
|
|
||||||
import net.kemitix.s3thorp.Sync.{Bucket, LocalFile, RemoteKey}
|
import net.kemitix.s3thorp.Sync.{Bucket, LocalFile, RemoteKey}
|
||||||
import software.amazon.awssdk.core.async.AsyncRequestBody
|
import software.amazon.awssdk.core.async.AsyncRequestBody
|
||||||
import software.amazon.awssdk.services.s3.model.{HeadObjectRequest, HeadObjectResponse, PutObjectRequest}
|
import software.amazon.awssdk.services.s3.model.{HeadObjectRequest, PutObjectRequest}
|
||||||
|
|
||||||
private class ReactiveS3Client
|
private class ReactiveS3Client
|
||||||
extends S3Client
|
extends S3Client
|
||||||
with CatsIOS3Client {
|
with CatsIOS3Client {
|
||||||
|
|
||||||
override def objectHead(bucket: Bucket, remoteKey: RemoteKey) = {
|
override def objectHead(bucket: Bucket, remoteKey: RemoteKey) = {
|
||||||
val request = HeadObjectRequest.builder()
|
val request = HeadObjectRequest.builder().bucket(bucket).key(remoteKey).build()
|
||||||
.bucket(bucket)
|
|
||||||
.key(remoteKey)
|
|
||||||
.build()
|
|
||||||
println(s"S3:HeadObject: $bucket : $remoteKey")
|
|
||||||
s3Client.headObject(request).attempt.map {
|
s3Client.headObject(request).attempt.map {
|
||||||
case Right(response) => {
|
case Right(response) => Some((response.eTag(), response.lastModified()))
|
||||||
println(s" -- ${response.eTag()} : ${response.lastModified()}")
|
case Left(_) =>None
|
||||||
Some((response.eTag(), response.lastModified()))
|
|
||||||
}
|
|
||||||
case Left(_) => {
|
|
||||||
println(" -- Not found in S3")
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def upload(localFile: LocalFile, bucket: Bucket, remoteKey: RemoteKey): IO[Unit] = {
|
override def upload(localFile: LocalFile, bucket: Bucket, remoteKey: RemoteKey): IO[Unit] = {
|
||||||
val request = PutObjectRequest.builder()
|
val request = PutObjectRequest.builder().bucket(bucket).key(remoteKey).build()
|
||||||
.bucket(bucket)
|
|
||||||
.key(remoteKey)
|
|
||||||
.build()
|
|
||||||
val body = AsyncRequestBody.fromFile(localFile)
|
val body = AsyncRequestBody.fromFile(localFile)
|
||||||
for {
|
for {
|
||||||
_ <- putStrLn(s"S3:PutObject: $bucket : $remoteKey")
|
|
||||||
_ <- s3Client.putObject(request, body)
|
_ <- s3Client.putObject(request, body)
|
||||||
_ <- putStrLn(" -- Done")
|
|
||||||
} yield ()
|
} yield ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue