Skip to content

Commit

Permalink
refactor: (#134) 필요없는 매개변수 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Oct 29, 2022
1 parent 73b255f commit eda8202
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ class AwsS3Adapter(
): UploadFilePort, CheckFilePort {

override fun upload(file: File): String {
inputS3(file, file.name)
inputS3(file)

return getResource(file.name)
}

override fun upload(files: List<File>): List<String> {
return files.map {
inputS3(it, it.name)
inputS3(it)
getResource(it.name)
}
}

private fun inputS3(file: File, fileName: String) {
private fun inputS3(file: File) {
try {
val inputStream = file.inputStream()
val objectMetadata = ObjectMetadata().apply {
this.contentLength = file.length()
this.contentType = Mimetypes.getInstance().getMimetype(file)
}

amazonS3Client.putObject(PutObjectRequest(awsProperties.bucket, fileName, inputStream, objectMetadata).withCannedAcl(CannedAccessControlList.PublicRead))
amazonS3Client.putObject(PutObjectRequest(awsProperties.bucket, file.name, inputStream, objectMetadata).withCannedAcl(CannedAccessControlList.PublicRead))
file.delete()
} catch (e: IOException) {
throw FileIOInterruptedException.EXCEPTION
Expand Down

0 comments on commit eda8202

Please sign in to comment.