Notice
Recent Posts
Recent Comments
Link
투케이2K
956. (Android/Java) [간단 소스] AccessKey , SecretKey 사용해 Aws S3 버킷 스토리지 AmazonS3Client 초기화 방법 본문
Android
956. (Android/Java) [간단 소스] AccessKey , SecretKey 사용해 Aws S3 버킷 스토리지 AmazonS3Client 초기화 방법
투케이2K 2025. 3. 15. 19:00[개발 환경 설정]
개발 툴 : AndroidStudio
개발 언어 : Java / Kotlin

[소스 코드]
// --------------------------------------------------------------------------------------
[개발 및 테스트 환경]
// --------------------------------------------------------------------------------------
- 언어 : Java / Kotlin
- 개발 툴 : AndroidStudio
- 기술 구분 : Aws / S3 / AccessKey / SecretKey
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[사전) 필요 설정 정리] : build.gradle 의존성 부여
// --------------------------------------------------------------------------------------
// [AWS] : [target 31 이상 의존성]
implementation 'com.amazonaws:aws-android-sdk-s3:2.57.0'
implementation 'com.amazonaws:aws-android-sdk-iot:2.57.0'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.57.0'
// [AWS] : [target 31 미만 의존성]
implementation 'com.amazonaws:aws-android-sdk-s3:2.16.13'
implementation 'com.amazonaws:aws-android-sdk-iot:2.16.13'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.16.13'
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[Java : 소스 코드]
// --------------------------------------------------------------------------------------
public boolean awsCredentialsInit(Context ctx, String accessKey, String secretKey, Region region) {
S_Log._D_(ACTIVITY_NAME + " :: setContext :: AWSCredentials 초기화 수행", new String[]{"accessKey :: " + String.valueOf(accessKey), "secretKey :: " + String.valueOf(secretKey), "region :: " + String.valueOf(AWS_S3_REGION)});
boolean returnData = false;
try {
mMainCtx = ctx;
if (C_Util.stringNotNull(accessKey) == true
&& C_Util.stringNotNull(secretKey) == true
&& region != null){ // [파라미터 null 체크 수행]
// [AWSCredentials 정의]
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
// [AmazonS3Client 초기화]
s3Client = new AmazonS3Client(credentials, region);
returnData = true;
}
}
catch (Exception e){
S_Log._printStackTrace_(null, S_FinalData.LOG_BUG_STATE, null, e);
}
return returnData;
}
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
[참고 사이트]
// --------------------------------------------------------------------------------------
[S3 (Amazon Simple Storage Service) 버킷 저장소 개념 및 설명 정리]
https://blog.naver.com/kkh0977/223733087281?trackingCode=blog_bloghome_searchlist
[S3 (Amazon Simple Storage Service) 버킷 저장소에 파일 업로드 방법]
https://blog.naver.com/kkh0977/223733106182?trackingCode=blog_bloghome_searchlist
// --------------------------------------------------------------------------------------
반응형
'Android' 카테고리의 다른 글
Comments