-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from SQUAD-D/feature#17/image-s3
S3 image upload
- Loading branch information
Showing
30 changed files
with
487 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/squad/board/RedisConfig.java → .../java/squad/board/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package squad.board.config; | ||
|
||
import com.amazonaws.auth.AWSCredentials; | ||
import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
import com.amazonaws.auth.BasicAWSCredentials; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
|
||
@Configuration | ||
public class S3Config { | ||
@Value("${cloud.aws.credentials.access-key}") | ||
private String accessKey; | ||
|
||
@Value("${cloud.aws.credentials.secret-key}") | ||
private String secretKey; | ||
|
||
@Value("${cloud.aws.region.static}") | ||
private String region; | ||
|
||
@Bean | ||
public AmazonS3 amazonS3Client() { | ||
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); | ||
return AmazonS3ClientBuilder | ||
.standard() | ||
.withCredentials(new AWSStaticCredentialsProvider(credentials)) | ||
.withRegion(region) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package squad.board.dto.board; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
public class ImageInfoRequest { | ||
private String imageUUID; | ||
private long imageSize; | ||
private String imageOriginalName; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/squad/board/dto/board/ImageInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package squad.board.dto.board; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public class ImageInfoResponse { | ||
private String imageUUID; | ||
private long imageSize; | ||
private String imageOriginalName; | ||
private String imageSrc; | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/squad/board/exception/comment/CommentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/squad/board/exception/image/ImageException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package squad.board.exception.image; | ||
|
||
import squad.board.commonresponse.CommonStatus; | ||
import squad.board.exception.CommonException; | ||
|
||
public class ImageException extends CommonException { | ||
public ImageException(CommonStatus status) { | ||
super(status); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/squad/board/exception/image/ImageStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package squad.board.exception.image; | ||
|
||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import squad.board.commonresponse.CommonStatus; | ||
|
||
@Getter | ||
public enum ImageStatus implements CommonStatus { | ||
IMAGE_SIZE_EXCEEDED(HttpStatus.valueOf(400), 500, "[이미지 크기 초과]이미지 파일 허용 크기는 5MB입니다."), | ||
IMAGE_NAME_SIZE_EXCEEDED(HttpStatus.valueOf(400), 501, "이미지명은 100자를 초과할 수 없습니다."), | ||
INVALID_IMAGE_EXTENSION(HttpStatus.valueOf(400), 502, "업로드가 불가능한 이미지 확장자입니다."); | ||
private final HttpStatus httpStatusCode; | ||
private final int code; | ||
private final String message; | ||
|
||
ImageStatus(HttpStatus httpStatusCode, int code, String message) { | ||
this.httpStatusCode = httpStatusCode; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package squad.board.repository; | ||
|
||
import org.apache.ibatis.annotations.Mapper; | ||
import squad.board.dto.board.ImageInfoRequest; | ||
|
||
import java.util.List; | ||
|
||
@Mapper | ||
public interface ImageMapper { | ||
void save(ImageInfoRequest request, Long boardId); | ||
|
||
// 이미지UUID로 파일이름 조회 | ||
List<String> findImageUUID(Long boardId); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.