Skip to content

Commit

Permalink
Fix | #106 | @lcomment | 이미지 업로드 관련 Request Body 수정
Browse files Browse the repository at this point in the history
* fix: 이미지 업로드 request body 삭제

* test: s3 관련 테스트 수정
  • Loading branch information
lcomment authored Mar 19, 2024
1 parent 4ef7e1e commit ac596b2
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 113 deletions.
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,10 +22,9 @@ 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)
}
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
95 changes: 32 additions & 63 deletions lovebird-api/src/main/resources/static/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,7 @@ <h4 id="_프로필_이미지_업로드_curl_request"><a class="link" href="#_프
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">$ curl 'http://localhost:8080/api/v1/images/profile' -i -X POST \
-H 'Content-Type: application/json;charset=UTF-8' \
-F '[email protected];type=image/png' \
-F 'imageUploadRequest={"providerId":"provider-id"};type=application/json'</code></pre>
-F '[email protected];type=image/png'</code></pre>
</div>
</div>
</div>
Expand All @@ -965,11 +964,6 @@ <h4 id="_프로필_이미지_업로드_http_request"><a class="link" href="#_프
Content-Type: image/png

image
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=imageUploadRequest
Content-Type: application/json

{"providerId":"provider-id"}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--</code></pre>
</div>
</div>
Expand Down Expand Up @@ -999,8 +993,7 @@ <h4 id="_프로필_이미지_업로드_httpie_request"><a class="link" href="#_
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">$ http --multipart POST 'http://localhost:8080/api/v1/images/profile' \
'Content-Type:application/json;charset=UTF-8' \
'image'@'image.png' \
'imageUploadRequest'='{"providerId":"provider-id"}'</code></pre>
'image'@'image.png'</code></pre>
</div>
</div>
</div>
Expand All @@ -1013,31 +1006,7 @@ <h4 id="_프로필_이미지_업로드_request_body"><a class="link" href="#_프
</div>
</div>
<div class="sect3">
<h4 id="_프로필_이미지_업로드_request_part-imageUploadRequest-fields"><a class="link" href="#_프로필_이미지_업로드_request_part-imageUploadRequest-fields">5.1.6. Request part-imageuploadrequest-fields</a></h4>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Path</th>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>providerId</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>com.lovebird.api.utils.restdocs.STRING@308af0df</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">소셜 제공자 ID</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="_프로필_이미지_업로드_response_body"><a class="link" href="#_프로필_이미지_업로드_response_body">5.1.7. Response body</a></h4>
<h4 id="_프로필_이미지_업로드_response_body"><a class="link" href="#_프로필_이미지_업로드_response_body">5.1.6. Response body</a></h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-json hljs" data-lang="json">{
Expand All @@ -1052,7 +1021,7 @@ <h4 id="_프로필_이미지_업로드_response_body"><a class="link" href="#_
</div>
</div>
<div class="sect3">
<h4 id="_프로필_이미지_업로드_response_fields"><a class="link" href="#_프로필_이미지_업로드_response_fields">5.1.8. Response fields</a></h4>
<h4 id="_프로필_이미지_업로드_response_fields"><a class="link" href="#_프로필_이미지_업로드_response_fields">5.1.7. Response fields</a></h4>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
Expand Down Expand Up @@ -2549,8 +2518,8 @@ <h5 id="_success_7_http_response"><a class="link" href="#_success_7_http_respons
"nickname" : "test",
"partnerNickname" : "test2",
"firstDate" : "2024-01-01",
"birthday" : "2024-03-17",
"partnerBirthday" : "2024-03-17",
"birthday" : "2024-03-19",
"partnerBirthday" : "2024-03-19",
"dayCount" : 48,
"nextAnniversary" : {
"kind" : "DAY",
Expand Down Expand Up @@ -2712,8 +2681,8 @@ <h4 id="_수정_http_request"><a class="link" href="#_수정_http_request">7.2.1
"imageUrl" : "test-image-url",
"email" : "test-email",
"nickname" : "test-nickname",
"birthday" : "2024-03-17",
"firstDate" : "2024-03-17",
"birthday" : "2024-03-19",
"firstDate" : "2024-03-19",
"gender" : "UNKNOWN"
}</code></pre>
</div>
Expand Down Expand Up @@ -4105,7 +4074,7 @@ <h3 id="_데이트_날짜_기준_다이어리_조회"><a class="link" href="#_
<h4 id="_데이트_날짜_기준_다이어리_조회_http_request"><a class="link" href="#_데이트_날짜_기준_다이어리_조회_http_request">10.2.1. HTTP request</a></h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/v1/diaries/memory-date?memoryDate=2024-03-17 HTTP/1.1
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/v1/diaries/memory-date?memoryDate=2024-03-19 HTTP/1.1
Authorization: Bearer access-token
Host: localhost:8080</code></pre>
</div>
Expand Down Expand Up @@ -4169,39 +4138,39 @@ <h4 id="_데이트_날짜_기준_다이어리_조회_http_response"><a class="li
"diaryId" : 1,
"userId" : 1,
"title" : "제목1",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소1",
"content" : "내용1",
"imageUrls" : [ "imageURL1" ]
}, {
"diaryId" : 2,
"userId" : 1,
"title" : "제목2",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소2",
"content" : "내용2",
"imageUrls" : [ "imageURL2" ]
}, {
"diaryId" : 3,
"userId" : 1,
"title" : "제목3",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소3",
"content" : "내용3",
"imageUrls" : [ "imageURL3" ]
}, {
"diaryId" : 4,
"userId" : 1,
"title" : "제목4",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소4",
"content" : "내용4",
"imageUrls" : [ "imageURL4" ]
}, {
"diaryId" : 5,
"userId" : 1,
"title" : "제목5",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소5",
"content" : "내용5",
"imageUrls" : [ "imageURL5" ]
Expand Down Expand Up @@ -4298,7 +4267,7 @@ <h3 id="_커서_기반_다이어리_리스트_조회"><a class="link" href="#_
<h4 id="_커서_기반_다이어리_리스트_조회_http_request"><a class="link" href="#_커서_기반_다이어리_리스트_조회_http_request">10.3.1. HTTP request</a></h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/v1/diaries/cursor?memoryDate=2024-03-17&amp;searchType=BEFORE&amp;diaryId=-1&amp;pageSize=10 HTTP/1.1
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/v1/diaries/cursor?memoryDate=2024-03-19&amp;searchType=BEFORE&amp;diaryId=-1&amp;pageSize=10 HTTP/1.1
Authorization: Bearer access-token
Host: localhost:8080</code></pre>
</div>
Expand Down Expand Up @@ -4374,86 +4343,86 @@ <h4 id="_커서_기반_다이어리_리스트_조회_http_response"><a class="li
"diaryId" : 1,
"userId" : 1,
"title" : "제목1",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용1",
"imageUrls" : [ ]
}, {
"diaryId" : 2,
"userId" : 2,
"title" : "제목2",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용2",
"imageUrls" : [ ]
}, {
"diaryId" : 3,
"userId" : 3,
"title" : "제목3",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용3",
"imageUrls" : [ ]
}, {
"diaryId" : 4,
"userId" : 4,
"title" : "제목4",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용4",
"imageUrls" : [ ]
}, {
"diaryId" : 5,
"userId" : 5,
"title" : "제목5",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용5",
"imageUrls" : [ ]
}, {
"diaryId" : 6,
"userId" : 6,
"title" : "제목6",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용6",
"imageUrls" : [ ]
}, {
"diaryId" : 7,
"userId" : 7,
"title" : "제목7",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용7",
"imageUrls" : [ ]
}, {
"diaryId" : 8,
"userId" : 8,
"title" : "제목8",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용8",
"imageUrls" : [ ]
}, {
"diaryId" : 9,
"userId" : 9,
"title" : "제목9",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용9",
"imageUrls" : [ ]
}, {
"diaryId" : 10,
"userId" : 10,
"title" : "제목10",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : null,
"content" : "내용10",
"imageUrls" : [ ]
} ],
"totalCount" : 10,
"diaryId" : 10,
"memoryDate" : "2024-03-17"
"memoryDate" : "2024-03-19"
}
}</code></pre>
</div>
Expand Down Expand Up @@ -4575,7 +4544,7 @@ <h4 id="_다이어리_상세_조회_http_response"><a class="link" href="#_다
"diaryId" : 1,
"userId" : 1,
"title" : "다이어리 제목",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소",
"content" : "내용",
"imageUrls" : [ ]
Expand Down Expand Up @@ -4668,7 +4637,7 @@ <h4 id="_다이어리_생성_http_request"><a class="link" href="#_다이어리_

{
"title" : "다이어리 제목",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소",
"content" : "내용",
"imageUrls" : [ "imageUrl1", "imageUrl2" ]
Expand All @@ -4682,7 +4651,7 @@ <h4 id="_다이어리_생성_request_body"><a class="link" href="#_다이어리_
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-json hljs" data-lang="json">{
"title" : "다이어리 제목",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소",
"content" : "내용",
"imageUrls" : [ "imageUrl1", "imageUrl2" ]
Expand Down Expand Up @@ -4819,7 +4788,7 @@ <h4 id="_다이어리_수정_http_request"><a class="link" href="#_다이어리_

{
"title" : "다이어리 제목 수정",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소",
"content" : "내용 수정",
"imageUrls" : [ "imageUrl1", "imageUrl2" ]
Expand All @@ -4833,7 +4802,7 @@ <h4 id="_다이어리_수정_request_body"><a class="link" href="#_다이어리_
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-json hljs" data-lang="json">{
"title" : "다이어리 제목 수정",
"memoryDate" : "2024-03-17",
"memoryDate" : "2024-03-19",
"place" : "장소",
"content" : "내용 수정",
"imageUrls" : [ "imageUrl1", "imageUrl2" ]
Expand Down Expand Up @@ -5016,7 +4985,7 @@ <h4 id="_다이어리_삭제_response_fields"><a class="link" href="#_다이어
<div id="footer">
<div id="footer-text">
Version 1.1.0-SNAPSHOT<br>
Last updated 2024-03-17 15:12:32 +0900
Last updated 2024-03-18 09:38:38 +0900
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
Expand Down
Loading

0 comments on commit ac596b2

Please sign in to comment.