feat: 커뮤니티 글 등록/수정

- 유료 글에서만 gif를 등록할 수 있도록 수정
This commit is contained in:
2025-07-03 15:26:35 +09:00
parent f13c221fd6
commit a8da17162a
3 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package kr.co.vividnext.sodalive.utils
import kr.co.vividnext.sodalive.common.SodaException
import org.apache.tika.Tika
import org.springframework.web.multipart.MultipartFile
/**
* 이미지 파일인지 확인하고,
* GIF의 경우 외부 조건(gifAllowed)에 따라 허용 여부 판단
*/
fun validateImage(file: MultipartFile, gifAllowed: Boolean) {
val mimeType = Tika().detect(file.bytes)
if (!mimeType.startsWith("image/")) {
throw SodaException("이미지 파일만 업로드할 수 있습니다.")
}
if (mimeType == "image/gif" && !gifAllowed) {
throw SodaException("GIF 파일은 유료 게시물만 업로드 할 수 있습니다.")
}
}