옵션
집 Skill 클라우드 인프라 aws-sdk-java-v2-s3

AWS SDK for Java 2.x를 사용한 Amazon S3 패턴 및 예제를 제공합니다. S3 버킷 작업, 오브젝트 업로드/다운로드, 멀티파트 업로드, 사전 서명된 URL, S3 전송 관리자, 오브젝트 작업 또는 S3 전용 구성 시 활용하십시오.

...모든 것을 확장하십시오
22
업데이트 된 시간 2026년 8월 24일

소개 aws-sdk-java-v2-s3

이 스킬은 AWS SDK for Java 2.x를 기반으로 한 Amazon S3 사용 패턴을 엄선하여 정리한 참고 자료입니다. 이 스킬은 Java 애플리케이션에서 S3 객체 스토리지를 올바르게 구현하는 데 자주 발생하는 문제, 즉 버킷 생성 및 관리, 올바른 요청 빌더를 사용한 객체 업로드 및 다운로드, 대용량 파일 처리, 임시 액세스 URL 생성, 그리고 이 모든 기능을 Spring Boot 애플리케이션에 통합하는 방법을 다룹니다. 개발자가 흩어진 문서들을 참고하여 SDK의 유연한 빌더 API를 직접 조합해야 하는 번거로움을 덜어주고, 서버 측 암호화 및 스토리지 클래스 선택과 같은 합리적인 기본값이 적용된, 바로 적용 가능한 코드 스니펫을 제공합니다.

이 자료는 핵심 오브젝트 라이프사이클(웨이터를 사용한 createBucket, RequestBody.fromFile을 통한 putObject, 경로를 통한 getObject, 일괄 deleteObjects), S3Presigner를 이용한 사전 서명된 URL 생성 및 유효 기간 설정, 대용량 파일 전송 최적화를 위한 S3 Transfer Manager를 다룹니다. 참조 파일에서는 재시도 정책을 포함한 클라이언트 설정, 오브젝트 작업, 전송 패턴, 그리고 동기/비동기 클라이언트, 반응형 서비스 템플릿, 메타데이터 인식 업로드, 접두사 목록 조회, 일괄 삭제를 포함한 다중 환경 Spring Boot 통합에 대해 더 깊이 다루고 있습니다. 빠른 참조 표는 각 작업을 해당 SDK 메서드와 매핑하고, 스토리지 클래스를 해당 사용 사례와 연결해 줍니다.

이 문서는 S3를 서비스에 통합하는 Java 백엔드 개발자 및 클라우드 엔지니어를 대상으로 하며, 특히 프로덕션 환경에 적합한 구성 예제가 필요한 Spring Boot 팀을 중점적으로 다룹니다. 대표적인 사용 사례로는 파일 저장 기능 구축, SDK v2로 마이그레이션, 사전 서명된 URL 공유 기능 추가, 대용량 파일 전송 최적화 등이 있습니다. 인증 정보는 일반적인 AWS 관행에 따라 표준 제공자와 외부 환경 변수를 통해 처리됩니다.

자주 묻는 질문

이 문서는 어떤 버전의 AWS SDK를 대상으로 합니까?

AWS SDK for Java 2.x입니다. 예제에서는 Maven 종속성 블록에서 S3 및 s3-transfer-manager 아티팩트를 버전 2.20.0으로 지정합니다.

대용량 파일 업로드도 다루고 있나요?

예. 이 문서는 최적화된 전송을 위한 S3 전송 관리자(Transfer Manager)를 설명하고, 100MB보다 큰 파일의 경우 멀티파트 업로드를 다루며, 빌더 기반의 UploadFileRequest 예제를 제공합니다.

인증 정보는 어떻게 처리됩니까?

표준 AWS 자격 증명 제공자를 통해 처리됩니다. Spring Boot 참조 문서에서는 프로필별 속성 파일에 정의된 외부 환경 변수(AWS_ACCESS_KEY / AWS_SECRET_KEY)를 기반으로 하는 StaticCredentialsProvider를 보여줍니다. 이는 비밀 정보를 임베드하는 방식이 아닌, 일반적인 구성 방식입니다.

Spring Boot와 함께 사용할 수 있나요?

네. 전용 참조 문서에서는 다중 환경 구성, 동기/비동기/전송 관리자/사전 서명 클라이언트를 위한 조건부 빈, 그리고 반응형 S3Service 템플릿을 다룹니다.

사전 서명된 URL의 최대 유효 기간은 얼마입니까?

간단한 참조 가이드에는 사전 서명된 URL의 최대 유효 기간이 7일이라고 명시되어 있으며, 예제에서는 10분의 서명 유효 기간을 사용합니다.

모든 파일

5개파일 references/s3-spring-boot-integration.md 20.7KB 보기 references/s3-object-operations.md 10.4KB 보기 references/s3-transfer-patterns.md14.6KB보기참조/s3-client-setup.md5.3KB보기SKILL.md9.3 KB보기
GitHub에서 보기

Overview

Provides patterns for S3 operations: bucket management, object upload/download with multipart support, presigned URLs, S3 Transfer Manager, and S3-specific configurations using AWS SDK for Java 2.x.

When to Use

  • Creating, listing, or deleting S3 buckets with proper configuration
  • Uploading or downloading objects from S3 with metadata and encryption
  • Working with multipart uploads for large files (>100MB) with error handling
  • Generating presigned URLs for temporary access to S3 objects
  • Copying or moving objects between S3 buckets with metadata preservation
  • Setting object metadata, storage classes, and access controls
  • Implementing S3 Transfer Manager for optimized file transfers
  • Integrating S3 with Spring Boot applications for cloud storage

Quick Reference

OperationMethodNotes
Create bucketcreateBucket()Wait with waiter().waitUntilBucketExists()
Upload objectputObject()Use RequestBody.fromFile()
Download objectgetObject()Streams to file or memory
Delete objectsdeleteObjects()Batch up to 1000 keys
Presigned URLpresigner.presignGetObject()Max 7 days expiration

Storage Classes

ClassUse Case
STANDARDFrequently accessed data
STANDARD_IAInfrequently accessed data
GLACIERLong-term archive
INTELLIGENT_TIERINGAutomatic cost optimization

Instructions

1. Add Dependencies

<dependency>    <groupId>software.amazon.awssdk</groupId>    <artifactId>s3</artifactId>    <version>2.20.0</version></dependency><dependency>    <groupId>software.amazon.awssdk</groupId>    <artifactId>s3-transfer-manager</artifactId>    <version>2.20.0</version></dependency>

2. Create S3 Client

S3Client s3Client = S3Client.builder()    .region(Region.US_EAST_1)    .build();// With retry logicS3Client s3Client = S3Client.builder()    .region(Region.US_EAST_1)    .overrideConfiguration(b -> b        .retryPolicy(RetryPolicy.builder()            .numRetries(3)            .build()))    .build();

3. Create Bucket

CreateBucketRequest request = CreateBucketRequest.builder()    .bucket(bucketName)    .build();s3Client.createBucket(request);// Wait until readys3Client.waiter().waitUntilBucketExists(    HeadBucketRequest.builder().bucket(bucketName).build());

4. Upload Object

PutObjectRequest request = PutObjectRequest.builder()    .bucket(bucketName)    .key(key)    .contentType("application/pdf")    .serverSideEncryption(ServerSideEncryption.AES256)    .storageClass(StorageClass.STANDARD_IA)    .build();s3Client.putObject(request, RequestBody.fromFile(Paths.get(filePath)));// Validate upload completionHeadObjectResponse headResp = s3Client.headObject(HeadObjectRequest.builder()    .bucket(bucketName)    .key(key)    .build());

5. Download Object

GetObjectRequest request = GetObjectRequest.builder()    .bucket(bucketName)    .key(key)    .build();s3Client.getObject(request, Paths.get(destPath));

6. Generate Presigned URL

try (S3Presigner presigner = S3Presigner.create()) {    GetObjectRequest getRequest = GetObjectRequest.builder()        .bucket(bucketName)        .key(key)        .build();    GetObjectPresignRequest presignRequest = GetObjectPresignRequest.builder()        .signatureDuration(Duration.ofMinutes(10))        .getObjectRequest(getRequest)        .build();    String url = presigner.presignGetObject(presignRequest).url().toString();}

7. Use Transfer Manager (Large Files)

try (S3TransferManager tm = S3TransferManager.create()) {    UploadFileRequest request = UploadFileRequest.builder()        .putObjectRequest(req -> req.bucket(bucketName).key(key))        .source(Paths.get(filePath))        .build();    FileUpload upload = tm.uploadFile(request);    CompletedFileUpload result = upload.completionFuture().join();}

Best Practices

Performance

  • Use S3 Transfer Manager: Automatic multipart uploads for files >100MB
  • Reuse S3 Client: Clients are thread-safe; reuse throughout application
  • Enable async operations: Use S3AsyncClient for I/O-bound operations
  • Configure timeouts: Set appropriate timeouts for large file operations

Security

  • Use temporary credentials: IAM roles or AWS STS for short-lived tokens
  • Enable encryption: Use AES-256 or AWS KMS for sensitive data
  • Use presigned URLs: Avoid exposing credentials with temporary access
  • Validate metadata: Sanitize user-provided metadata

Error Handling

  • Implement retry logic: Exponential backoff for network operations
  • Handle throttling: Proper handling of 429 responses
  • Clean up failures: Abort failed multipart uploads

Cost Optimization

  • Use appropriate storage classes: STANDARD, STANDARD_IA, INTELLIGENT_TIERING
  • Implement lifecycle policies: Automatic transition/expiration
  • Minimize API calls: Use batch operations when possible

Constraints and Warnings

  • Object Size: Single PUT limited to 5GB; use multipart for larger files
  • Bucket Names: Must be globally unique across all AWS accounts
  • Object Immutability: Objects cannot be modified; must be replaced entirely
  • Eventual Consistency: List operations may have slight delays after uploads
  • Presigned URLs: Maximum expiration time is 7 days
  • Multipart Uploads: Parts must be at least 5MB except last part

Examples

Complete Upload Workflow with Validation

// 1. Upload with validationPutObjectRequest putRequest = PutObjectRequest.builder()    .bucket(bucketName)    .key(key)    .contentType(contentType)    .build();s3Client.putObject(putRequest, RequestBody.fromFile(Paths.get(filePath)));// 2. Validate with headObjectHeadObjectResponse headResp = s3Client.headObject(HeadObjectRequest.builder()    .bucket(bucketName)    .key(key)    .build());// 3. Verify metadatalong fileSize = Files.size(Paths.get(filePath));if (headResp.contentLength() != fileSize) {    throw new IllegalStateException("Upload size mismatch");}

Multipart Upload with Abort-on-Failure

// 1. Initiate multipart uploadCreateMultipartUploadRequest createRequest = CreateMultipartUploadRequest.builder()    .bucket(bucketName)    .key(key)    .build();CreateMultipartUploadResponse multipartUpload = s3Client.createMultipartUpload(createRequest);String uploadId = multipartUpload.uploadId();try {    // 2. Upload parts    List<CompletedPart> parts = new ArrayList<>();    int partNumber = 1;    byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));    int chunkSize = 5 * 1024 * 1024; // 5MB minimum    for (int offset = 0; offset < fileBytes.length; offset += chunkSize) {        int length = Math.min(chunkSize, fileBytes.length - offset);        UploadPartRequest uploadPartRequest = UploadPartRequest.builder()            .bucket(bucketName)            .key(key)            .uploadId(uploadId)            .partNumber(partNumber)            .build();        UploadPartResponse partResponse = s3Client.uploadPart(uploadPartRequest,            RequestBody.fromBytes(Arrays.copyOfRange(fileBytes, offset, offset + length)));        parts.add(CompletedPart.builder()            .partNumber(partNumber)            .eTag(partResponse.eTag())            .build());        partNumber++;    }    // 3. Complete multipart upload    CompleteMultipartUploadRequest completeRequest = CompleteMultipartUploadRequest.builder()        .bucket(bucketName)        .key(key)        .uploadId(uploadId)        .multipartUpload(CompletedMultipartUpload.builder().parts(parts).build())        .build();    s3Client.completeMultipartUpload(completeRequest);} catch (Exception e) {    // 4. Abort on failure    AbortMultipartUploadRequest abortRequest = AbortMultipartUploadRequest.builder()        .bucket(bucketName)        .key(key)        .uploadId(uploadId)        .build();    s3Client.abortMultipartUpload(abortRequest);    throw new RuntimeException("Upload failed, cleanup performed", e);}

References

  • references/s3-client-setup.md — Client configuration and basic operations
  • references/s3-object-operations.md — Advanced object operations
  • references/s3-transfer-patterns.md — Transfer Manager and multipart uploads
  • references/s3-spring-boot-integration.md — Spring Boot integration patterns
  • AWS S3 Developer Guide
  • AWS SDK for Java 2.x S3 API

Related Skills

  • aws-sdk-java-v2-core - Core AWS SDK patterns and configuration
  • spring-boot-dependency-injection - Spring dependency injection patterns

모든 파일

0개 파일

aws-sdk-java-v2-s3 설치

스킬 파일을 다운로드하여 .claude/skills/ 디렉터리에 압축을 풀어주세요.

ZIP 다운로드

저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.

git clone https://github.com/giuseppe-trisciuoglio/developer-kit/blob/main/plugins/developer-kit-java/skills/aws-sdk-java-v2-s3/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

복사 복사
빠른 설정: skill 폴더를 .claude/skills/로 복사하면 Claude가 해당 스킬을 자동으로 감지하여 사용합니다.

관련 스킬

Cloudflare Manager
업데이트 된 시간 2026년 6월 29일
pinecone
업데이트 된 시간 2026년 6월 29일
azure-setup-guide
업데이트 된 시간 2026년 6월 29일
sentry-architecture-variants
업데이트 된 시간 2026년 6월 29일
OR