Skip to content

Commit

Permalink
🐛fix: 이미지 업로드 에러 해결 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxoznge authored Jun 11, 2024
1 parent 5061fe9 commit ce72131
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class CardController {
@PostMapping(value = "", consumes = "multipart/form-data")
public ApiResponse<CardCreateResponse> createCard(
@UserResolver User authUser,
@RequestPart @Valid CardCreateRequest request,
@RequestPart(value = "request") @Valid CardCreateRequest request,
@RequestPart(name = "cardImage") MultipartFile file
) {
return ApiResponse.onSuccess(cardService.createCard(authUser, request, file));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.ddabong.ddabongdotchiBE.domain.global;

import java.lang.reflect.Type;

import org.springframework.http.MediaType;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.ObjectMapper;

@Component
public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter {

/**
* Converter for support http request with header Content-Type: multipart/form-data
*/
public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) {
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM);
}

@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
return false;
}

@Override
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
return false;
}

@Override
protected boolean canWrite(MediaType mediaType) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class UserController {

@PostMapping(value = "/join", consumes = "multipart/form-data")
public ApiResponse<UserJoinResponse> join(
@Valid @RequestPart UserJoinRequest request,
@RequestPart(value = "request") @Valid UserJoinRequest request,
@RequestPart(name = "profileImage") MultipartFile file
) {
return ApiResponse.onSuccess(userService.join(request, file));
Expand Down

0 comments on commit ce72131

Please sign in to comment.