Skip to content

Commit

Permalink
Merge pull request #50 from LIKELION-TEAM4-HACKATHON/connect-S3-bucket
Browse files Browse the repository at this point in the history
S3 버킷 연결
  • Loading branch information
chaeyoungeee authored Jul 25, 2024
2 parents 6ebb3d7 + 8944105 commit 428c943
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 2 deletions.
Binary file modified .gradle/8.8/checksums/checksums.lock
Binary file not shown.
Binary file modified .gradle/8.8/checksums/md5-checksums.bin
Binary file not shown.
Binary file modified .gradle/8.8/checksums/sha1-checksums.bin
Binary file not shown.
Binary file modified .gradle/8.8/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/8.8/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ dependencies {

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

// 파일 업로드
implementation 'commons-io:commons-io:2.6'
implementation 'commons-fileupload:commons-fileupload:1.4'

}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ResponseEntity<MemberInfoResponse> getMyInfo(@AuthenticationPrincipal Use
MemberInfoResponse memberInfo = memberService.getMemberInfoByEmail(email);

log.info("멤버 정보 조회 성공: {}", memberInfo.getUsername());

return ResponseEntity.ok(memberInfo);
}

Expand All @@ -38,4 +38,4 @@ public ResponseEntity<MemberInfoResponse> getMemberInfo(@PathVariable("userId")

return ResponseEntity.ok(memberInfo);
}
}
}
31 changes: 31 additions & 0 deletions src/main/java/likelion/MZConnent/config/S3Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package likelion.MZConnent.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.AmazonS3Client;
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;

@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 AmazonS3Client amazonS3Client(){
BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey);
return (AmazonS3Client) AmazonS3ClientBuilder.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.build();
}
}

0 comments on commit 428c943

Please sign in to comment.