Skip to content

Commit

Permalink
added fileName
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterITA committed Jun 5, 2024
1 parent 64ecc19 commit 858f140
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ trait FileManager {

def close(): Unit

def generateGetPresignedUrl(containerPath: String, path: String): Try[String]
def generateGetPresignedUrl(bucketName: String, path: String, fileName: String): Try[String]

def generatePutPresignedUrl(containerPath: String, path: String): Try[String]
def generatePutPresignedUrl(bucketName: String, path: String, fileName: String): Try[String]
}

object FileManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ final class FileManagerImpl(blockingExecutionContext: ExecutionContextExecutor)
pathCreated.resolve(fileName.stripMargin('/'))
}

override def generateGetPresignedUrl(containerPath: String, path: String): Try[String] = Try(path)
override def generateGetPresignedUrl(bucketName: String, path: String, fileName: String): Try[String] = {
val path: String = createPath(path, "", fileName).toAbsolutePath.toString
Try(path)
}

override def generatePutPresignedUrl(containerPath: String, path: String): Try[String] = Try(path)
override def generatePutPresignedUrl(bucketName: String, path: String, fileName: String): Try[String] = {
val path: String = createPath(path, "", fileName).toAbsolutePath.toString
Try(path)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ final class S3ManagerImpl(blockingExecutionContext: ExecutionContextExecutor)(

def calcContentMd5(byteArray: Array[Byte]): String = new String(Base64.encodeBase64(DigestUtils.md5(byteArray)))

override def generateGetPresignedUrl(bucketName: String, keyName: String): Try[String] = {
override def generateGetPresignedUrl(bucketName: String, path: String, fileName: String): Try[String] = {
val key: String = s3Key(path, "", fileName)

Using(S3Presigner.create()) { s3Presigner =>
val objectRequest: GetObjectRequest = GetObjectRequest
.builder()
.bucket(bucketName)
.key(keyName)
.key(key)
.build()

val presignRequest: GetObjectPresignRequest = GetObjectPresignRequest
Expand All @@ -186,12 +188,14 @@ final class S3ManagerImpl(blockingExecutionContext: ExecutionContextExecutor)(
}
}

override def generatePutPresignedUrl(bucketName: String, keyName: String): Try[String] = {
override def generatePutPresignedUrl(bucketName: String, path: String, fileName: String): Try[String] = {
val key: String = s3Key(path, "", fileName)

Using(S3Presigner.create()) { s3Presigner =>
val objectRequest: PutObjectRequest = PutObjectRequest
.builder()
.bucket(bucketName)
.key(keyName)
.key(key)
.build()

val presignRequest: PutObjectPresignRequest = PutObjectPresignRequest
Expand Down

0 comments on commit 858f140

Please sign in to comment.