Skip to content

Commit

Permalink
feat: 이미지 파일 업로드#7
Browse files Browse the repository at this point in the history
  • Loading branch information
firefox1234123 committed Aug 1, 2024
1 parent 8a110e0 commit 2b69894
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.skhu.likelion12thteam03be.user.domain.repository.UserRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
Expand All @@ -37,7 +38,7 @@ public class PostService {
private final UserRepository userRepository;

@Transactional
public void postSave(PostSaveReqDto postSaveReqDto, MultipartFile multipartFile, Principal principal) throws IOException {
public void postSave(PostSaveReqDto postSaveReqDto, @RequestPart(required = false) MultipartFile multipartFile, Principal principal) throws IOException {
String imgUrl = s3Service.upload(multipartFile, "post");
String loginId = principal.getName();

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ spring:
username: ${spring.datasource.username}
password: ${spring.datasource.password}
driver-class-name: com.mysql.cj.jdbc.Driver
servlet:
multipart:
maxFileSize: 10MB # 파일 하나의 최대 크기
maxRequestSize: 30MB # 한 번에 최대 업로드 가능 용량
jpa:
database: mysql
hibernate:
Expand Down

0 comments on commit 2b69894

Please sign in to comment.