Files
goplt/docs/content/stories/epic5/5.3-blob-storage.md

2.0 KiB

Story 5.3: Blob Storage System

Metadata

  • Story ID: 5.3
  • Title: Blob Storage System
  • Epic: 5 - Infrastructure Adapters
  • Status: Pending
  • Priority: Medium
  • Estimated Time: 5-6 hours
  • Dependencies: 1.1, 1.5

Goal

Implement a complete blob storage system using S3 with a clean interface for file upload, download, and management.

Description

This story implements S3-based blob storage with support for file uploads, downloads, signed URLs, and file deletion. It includes an API endpoint for file uploads.

Deliverables

1. Blob Storage Interface (pkg/infra/blob/blob.go)

  • BlobStore interface with:
    • Upload(ctx context.Context, key string, data []byte) error
    • Download(ctx context.Context, key string) ([]byte, error)
    • Delete(ctx context.Context, key string) error
    • GetSignedURL(ctx context.Context, key string, ttl time.Duration) (string, error)
    • Exists(ctx context.Context, key string) (bool, error)

2. S3 Implementation (internal/infra/blob/s3_store.go)

  • AWS S3 client setup
  • All interface methods implemented
  • Error handling
  • Content type detection

3. File Upload API

  • POST /api/v1/files/upload - Upload file
  • File validation
  • Size limits
  • Content type validation

4. Configuration

  • S3 config in config/default.yaml:
    • Bucket name
    • Region
    • Credentials (or use IAM role)

5. DI Integration

  • Provider function for BlobStore
  • Register in DI container

Acceptance Criteria

  • Blob storage interface is defined
  • S3 implementation works correctly
  • Files can be uploaded and downloaded
  • Signed URLs are generated correctly
  • File upload API works
  • Configuration is loaded from config
  • Blob store is injectable via DI

Files to Create/Modify

  • pkg/infra/blob/blob.go - Blob storage interface
  • internal/infra/blob/s3_store.go - S3 implementation
  • internal/infra/blob/handler.go - File upload handler
  • internal/di/providers.go - Add blob store provider
  • config/default.yaml - Add S3 config