Skip to content

Commit

Permalink
applied suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterITA committed Jun 10, 2024
1 parent 6db27cf commit f352cc9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import akka.http.scaladsl.server.directives.FileInfo
import it.pagopa.interop.commons.files.service.impl.{FileManagerImpl, S3ManagerImpl}

import java.io.{ByteArrayOutputStream, File}
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.Try

Expand Down Expand Up @@ -42,9 +43,9 @@ trait FileManager {

def close(): Unit

def generateGetPresignedUrl(bucketName: String, path: String, fileName: String, duration: Int): Try[String]
def generateGetPresignedUrl(bucketName: String, path: String, fileName: String, durationInMinutes: FiniteDuration): Try[String]

def generatePutPresignedUrl(bucketName: String, path: String, fileName: String, duration: Int): Try[String]
def generatePutPresignedUrl(bucketName: String, path: String, fileName: String, durationInMinutes: FiniteDuration): Try[String]
}

object FileManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.nio.file.{Files, Path, Paths, StandardCopyOption}
import scala.concurrent.{ExecutionContextExecutor, Future}
import java.nio.file.FileVisitOption
import java.util.stream.Collectors
import scala.concurrent.duration.FiniteDuration
import scala.jdk.CollectionConverters._
import scala.util.Try

Expand Down Expand Up @@ -90,7 +91,7 @@ final class FileManagerImpl(blockingExecutionContext: ExecutionContextExecutor)
bucketName: String,
path: String,
fileName: String,
duration: Int
duration: FiniteDuration
): Try[String] = {
val destPath: String = createPath(path, "", fileName).toAbsolutePath.toString
Try(destPath)
Expand All @@ -100,7 +101,7 @@ final class FileManagerImpl(blockingExecutionContext: ExecutionContextExecutor)
bucketName: String,
path: String,
fileName: String,
duration: Int
durationInMinutes: FiniteDuration
): Try[String] = {
val destPath: String = createPath(path, "", fileName).toAbsolutePath.toString
Try(destPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.io.{ByteArrayOutputStream, File}
import java.nio.file.Files
import java.time.Duration
import java.util.concurrent.Executor
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future}
import scala.jdk.CollectionConverters._
import scala.jdk.FutureConverters._
Expand Down Expand Up @@ -171,7 +172,7 @@ final class S3ManagerImpl(blockingExecutionContext: ExecutionContextExecutor)(
bucketName: String,
path: String,
fileName: String,
duration: Int
durationInMinutes: FiniteDuration
): Try[String] = {
val key: String = s3Key(path, "", fileName)

Expand All @@ -184,7 +185,7 @@ final class S3ManagerImpl(blockingExecutionContext: ExecutionContextExecutor)(

val presignRequest: GetObjectPresignRequest = GetObjectPresignRequest
.builder()
.signatureDuration(Duration.ofMinutes(duration.toLong))
.signatureDuration(Duration.ofMinutes(durationInMinutes.length))
.getObjectRequest(objectRequest)
.build()

Expand All @@ -197,7 +198,7 @@ final class S3ManagerImpl(blockingExecutionContext: ExecutionContextExecutor)(
bucketName: String,
path: String,
fileName: String,
duration: Int
durationInMinutes: FiniteDuration
): Try[String] = {
val key: String = s3Key(path, "", fileName)

Expand All @@ -210,7 +211,7 @@ final class S3ManagerImpl(blockingExecutionContext: ExecutionContextExecutor)(

val presignRequest: PutObjectPresignRequest = PutObjectPresignRequest
.builder()
.signatureDuration(Duration.ofMinutes(duration.toLong))
.signatureDuration(Duration.ofMinutes(durationInMinutes.length))
.putObjectRequest(objectRequest)
.build()

Expand Down

0 comments on commit f352cc9

Please sign in to comment.