Skip to content

Commit

Permalink
Remove huge dependency from S3 file uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
mkSpace committed Jun 24, 2024
1 parent d861d29 commit afc8ced
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.whatever.raisedragon.infra.s3

import com.whatever.raisedragon.aws.s3.S3Agent
import com.whatever.raisedragon.external.aws.s3.S3Agent
import org.springframework.context.annotation.Profile
import org.springframework.stereotype.Service
import org.springframework.web.multipart.MultipartFile
Expand All @@ -12,10 +12,19 @@ class S3ApplicationService(
) : FileUploader {

override fun upload(multipartFile: MultipartFile): String {
return s3Agent.upload(S3_PREFIX_DIRECTORY, multipartFile)
return s3Agent.upload(
fileInputStreamSource = multipartFile,
directoryName = S3_PREFIX_DIRECTORY,
originalFileName = multipartFile.originalFilename ?: DEFAULT_ORIGINAL_FILE_NAME,
contentType = multipartFile.contentType ?: DEFAULT_CONTENT_TYPE,
size = multipartFile.size
)
}

companion object {
private const val S3_PREFIX_DIRECTORY = "gifticon/"

private const val DEFAULT_ORIGINAL_FILE_NAME = "default-file-name"
private const val DEFAULT_CONTENT_TYPE = "multipart/form-data"
}
}
}

0 comments on commit afc8ced

Please sign in to comment.