Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lcomment committed Mar 21, 2024
2 parents 2284e23 + 9a650ed commit fe3c541
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class JwtExceptionFilter : OncePerRequestFilter() {
}

fun setErrorResponse(returnCode: ReturnCode, response: HttpServletResponse) {
response.status = HttpStatus.BAD_REQUEST.value()
response.status = HttpStatus.UNAUTHORIZED.value()
response.contentType = "application/json; charset=UTF-8"

val result: ApiResponse<String> = ApiResponse.fail(returnCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.lovebird.api.controller.external

import com.lovebird.api.annotation.AuthorizedUser
import com.lovebird.api.dto.param.external.DiaryImagesUploadParam
import com.lovebird.api.dto.request.external.ProfileImageUploadRequest
import com.lovebird.api.dto.param.external.ProfileImageUploadParam
import com.lovebird.api.service.external.S3ImageService
import com.lovebird.common.response.ApiResponse
import com.lovebird.domain.entity.User
Expand All @@ -22,18 +22,17 @@ class S3ImageController(

@PostMapping("/profile")
fun uploadProfileImage(
@RequestPart(value = "image") image: MultipartFile,
@RequestPart(value = "imageUploadRequest") request: ProfileImageUploadRequest
@RequestPart(value = "image") image: MultipartFile
): ApiResponse<FileUploadResponse> {
val fileUploadResponse = s3ImageService.uploadProfileImage(request.toParam(image))
val fileUploadResponse = s3ImageService.uploadProfileImage(ProfileImageUploadParam.from(image))

return ApiResponse.success(fileUploadResponse)
}

@PostMapping("/diary")
fun uploadDiaryImages(
@AuthorizedUser user: User,
@RequestPart(value = "images") images: List<MultipartFile>
@RequestPart(value = "image") images: List<MultipartFile>
): ApiResponse<FileUploadListResponse> {
val fileUploadListResponse = s3ImageService.uploadDiaryImages(DiaryImagesUploadParam.of(images, user.id!!))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package com.lovebird.api.dto.param.external

import com.lovebird.common.enums.Domain
import org.springframework.web.multipart.MultipartFile

data class ProfileImageUploadParam(
val image: MultipartFile,
val domain: String,
val providerId: String
)
val domain: String
) {
companion object {

fun from(image: MultipartFile): ProfileImageUploadParam {
return ProfileImageUploadParam(
image = image,
domain = Domain.PROFILE.lower()
)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PresignedUrlService(
}

fun getProfilePresignedUrl(param: ProfileUploadPresignedUrlParam): PresignedUrlResponse {
val newFilename: String = FilenameUtils.generateProfileImageName(param.filename, param.providerId)
val newFilename: String = FilenameUtils.generateProfileImageName(param.filename)
val presignedUrl: String = presignedUrlProvider.getUploadPresignedUrl(Domain.PROFILE.lower(), null, newFilename)

return PresignedUrlResponse(presignedUrl, newFilename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class S3ImageService(
) {

fun uploadProfileImage(param: ProfileImageUploadParam): FileUploadResponse {
val newFileName: String = generateProfileImageName(param.image.originalFilename!!, param.providerId)
val newFileName: String = generateProfileImageName(param.image.originalFilename!!)

return fileUploadService.upload(FileUploadRequest(param.image, newFileName, param.domain, null))
}
Expand Down
4 changes: 4 additions & 0 deletions lovebird-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ spring:
- fcm.yml
- logging-${spring.profiles.default}.yml
- monitoring.yml
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB

apple:
test-code: ${APPLE_TEST_CODE}
Expand Down
Loading

0 comments on commit fe3c541

Please sign in to comment.