Skip to content

Commit

Permalink
[Feat] s3 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
bayy1216 committed Jun 1, 2024
1 parent ef15b77 commit 3773b2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("prod")
public class AwsS3Config {
@Value("${cloud.aws.credentials.access-key}")
private String accessKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import lombok.RequiredArgsConstructor;
import org.haedal.zzansuni.domain.ImageUploader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.UUID;

@Component
@Order(1)
@Profile("prod")
@RequiredArgsConstructor
public class FakeUploader implements ImageUploader {
private final AmazonS3 amazonS3;
Expand Down Expand Up @@ -51,3 +55,12 @@ public String upload(MultipartFile imageFile) {
return amazonS3.getUrl(bucket, uniqueFilename).toString();
}
}

@Component
@Order(2)
class MockUploader implements ImageUploader {
@Override
public String upload(MultipartFile imageFile) {
return "https://example.com/image.jpg";
}
}

0 comments on commit 3773b2b

Please sign in to comment.