Skip to content

Commit

Permalink
merge: (#134) InputS3 매개변수 정리 (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 authored Oct 30, 2022
2 parents 73b255f + eda8202 commit 886fd38
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 886fd38

Please sign in to comment.