-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
๐ง [STMT-146] ํ์ผ ์ ๋ก๋ ๊ธฐ๋ฅ ์ฝ๋ ๋ฆฌ๋ทฐ ๋ฐ์ #89
Conversation
โฆSTMT-146-fix-file-upload
โฆSTMT-146-fix-file-upload
src/main/java/com/stumeet/server/file/adapter/in/FileUploadApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/stumeet/server/file/adapter/out/S3ImageStorageAdapter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/stumeet/server/common/exception/model/NotImplementedException.java
Outdated
Show resolved
Hide resolved
src/main/java/com/stumeet/server/common/util/model/ValidImageContentType.java
Outdated
Show resolved
Hide resolved
์ด์ ์๋ ๋ค์๋ ์๊ฐ์ด์ง๋ง contentType + ํ์ผ๋ช
์
๊ธ๋ก๋ฒ ์์ธ ํธ๋ค๋ฌ์์ ์ก์์ ์ถ๋ ฅํด์ฃผ์ด๋ ์ถฉ๋ถํ ๊ฒ ๊ฐ์ต๋๋ค! ๐
ํจํค์ง ์์น๋ ๊ด์ฐฎ์๊ฑฐ ๊ฐ์ต๋๋ค.
ํน์ ๋๋ฉ์ธ์ ์ข
์๋ ์ ํธ ํด๋์ค๋ผ๋ฉด ํด๋นํ๋ ๋๋ฉ์ธ์ utils ํจํค์ง๋ฅผ ๋ง๋ค์ด์ ๊ด๋ฆฌํด๋ ๊ด์ฐฎ์ ๋ฏ ํฉ๋๋ค. |
Co-authored-by: zxcv9203 <41960243+zxcv9203@users.noreply.github.com>
Co-authored-by: zxcv9203 <41960243+zxcv9203@users.noreply.github.com>
๋ฌ์์ฃผ์ ํผ๋๋ฐฑ ํ์ธํ์ต๋๋ค! ๋ฆฌ๋ทฐ ๋ฐ์ + ํ
์คํธ์ฉ ์ฝ๋๋ฅผ ์ญ์ ํ๊ณ ๋ค์ ๋ฆฌ๋ทฐ ์์ฒญ ๋๋ฆฌ๊ฒ ์ต๋๋ค. |
- `FileUtil` -> `ImageFileUtil` - `ValidImageContentType` -> `ImageContentType`
- `String.contains`๋ฅผ ์ฌ์ฉํ ๋ `image/jpeg`, ํ์ฅ์ jpg์ ์ด๋ฏธ์ง์ ๊ฒฝ์ฐ ์ ํจํ ์ด๋ฏธ์ง๊ฐ ์๋๋ผ๋ ์์ธ๊ฐ ๋ฐ์ - ImageContentType์ extension์ ์ถ๊ฐํด contentType๊ณผ extension์ ๋น๊ตํ๋ ๋ก์ง ์ถ๊ฐ
src/main/java/com/stumeet/server/common/annotation/validator/NullOrImageFileValidator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/stumeet/server/file/adapter/out/S3ImageStorageAdapter.java
Show resolved
Hide resolved
โฆSTMT-146-fix-file-upload
- `ErrorCode` ์์ ๋๋ฝ๋ ์ฝ๋ ์ถ๊ฐ
- !๋ฅผ ๋ถ์ด์ง ์์ ๋ ผ๋ฆฌ ์ค๋ฅ์ test์์ ๋ฐ๋ผ๋ ๊ฒฐ๊ณผ์ ๋ค๋ฅธ ์๋ต์ ์ฃผ์ด์ ํ ์คํธ๊ฐ ํต๊ณผ๊ฐ ๋์ง ์์์ต๋๋ค. - ์ถ์ถํ content type์ด non null์ผ ๊ฒฝ์ฐ, ์์คํ ๋ด๋ถ์์ ์ ํด์ง content type ๋ชฉ๋ก์ ํฌํจ๋์ง ์๋ ํ์ฅ์์ ๊ฒฝ์ฐ Unsupported media type๊ณผ Bad Reqeust ๋ ์ค์ ์ด๋ค ์ํ์ฝ๋๋ฅผ ๋ณด๋ผ์ง ๊ณ ๋ฏผํ๋๋ฐ, Validator์ธ๋งํผ ์ ํจ์ฑ์ ํ๋จํ๋ค๊ณ ์๊ฐํ์ฌ `BadRequest` ์ํ์ฝ๋๋ฅผ ํต์ผํ์ฌ ์๋ตํ๊ธฐ๋ก ๊ฒฐ์ ํ์์ต๋๋ค.
๐ ํด๊ฒฐํ๋ ค๋ ๋ฌธ์ ๋ฅผ ์ ์ด์ฃผ์ธ์
๐ค ์ด๋ค ๋ฐฉ์์ผ๋ก ํด๊ฒฐํ๋์ง ์ ์ด์ฃผ์ธ์
BusinessException
์ ์์๋ฐ๋NotImplementedException
๋ฅผ ๊ตฌํํ์ฌ ๊ตฌํ๋์ง ์์ ๋ฉ์๋ ์ฌ์ฉ ์ ์์ธ ๋์ง๊ธฐoriginalFileName
์์ ๋ฌธ์์ด์ ์ถ์ถํ๋ ๊ฒ๋ณด๋ค๋contentType
์ ๊ฐ์ ธ์ ๊ฒ์ฌํ๋ ๊ฒ์ด ๋ซ๋ค๊ณ ํ๋จํ์ฌ ์์ ํ์์ต๋๋ค.๐ ์ค์ ์ ์ผ๋ก ๋ฆฌ๋ทฐ ํ์ผ๋ฉด ํ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด ์ ์ด์ฃผ์ธ์
GlobalExceptionController
์ ์์WARN_LOG_MESSAGE
๋ฅผ ๊ฐ์ ธ์์ ์ฌ์ฉํด๋ ๋๋์ง, ์๋๋ ์ด์ ๊ฐ ์๋ค๋ฉด ์ด๋ป๊ฒ ๊ตฌํํ๋ฉด ์ข์์ง.Constant
ํด๋์ค๋ฅผ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ์๊ฐํ์ต๋๋ค.ValidImageContentType
์ ํจํค์ง ์์นFileUtil
๊ณผ ๊ด๋ จ๋ ํ์ผ์ด๋ utils์ ๋ฃ์๋๋ฐ ๋น์ฆ๋์ค ๊ท์น๊ณผ ์ฐ๊ด๋ ํด๋์ค์ธ๋ฏ๋ ํ์ฌ ์ด๋์ ์์น์์ผ์ผ ํ ์ง ๊ณ ๋ฏผ์ด ๋ฉ๋๋ค.