feat: add storage module with S3 support and development tooling
Create shared storage module for AWS S3 operations with comprehensive development infrastructure: Core Features: - S3 interface with two upload patterns (manager and direct) - Presigned URL generation with 15-minute expiration - Support for multipart uploads and direct PutObject - Comprehensive test coverage (8 tests, 70.4% coverage) - Generic implementation without project-specific dependencies Development Tooling: - .editorconfig for consistent editor settings - .pre-commit-config.yaml with Go linters and formatters - .golangci.yml for golangci-lint configuration - commitlint.config.js for conventional commit validation - cliff.toml for automated changelog generation (v0.0.1) - renovate.json for automated dependency updates - .gitlab-ci.yml for CI/CD pipeline CI/CD Pipeline: - Automated testing with race detection - Coverage tracking and Codecov integration - Vulnerability scanning with govulncheck - Pre-commit validation gates - Release automation Module exports: - New(bucket) - Upload manager pattern for large files - NewS3(cfg, bucket) - Direct upload pattern - Store(path, content, contentType) - Upload and get presigned URL 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# Storage Module
|
||||
|
||||
Shared storage utilities for AWS S3.
|
||||
|
||||
## Features
|
||||
|
||||
- S3 object storage with presigned URL generation
|
||||
- Two upload strategies: managed uploads (for large files) and direct uploads
|
||||
- Configurable part size for multipart uploads
|
||||
- 15-minute presigned URL expiration
|
||||
|
||||
## Usage
|
||||
|
||||
### Using the Upload Manager (recommended for large files)
|
||||
|
||||
```go
|
||||
import "gitlab.com/unboundsoftware/storage"
|
||||
|
||||
// Create storage with automatic AWS config loading
|
||||
s3Storage, err := storage.New("my-bucket")
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
// Upload a file and get a presigned URL
|
||||
url, err := s3Storage.Store("path/to/file.pdf", fileReader, "application/pdf")
|
||||
```
|
||||
|
||||
### Using Direct Upload (for smaller files or custom config)
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"gitlab.com/unboundsoftware/storage"
|
||||
)
|
||||
|
||||
// Load custom AWS config
|
||||
cfg, err := config.LoadDefaultConfig(context.Background())
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
// Create storage with custom config
|
||||
s3Storage := storage.NewS3(cfg, "my-bucket")
|
||||
|
||||
// Upload a file and get a presigned URL
|
||||
url, err := s3Storage.Store("path/to/file.pdf", fileReader, "application/pdf")
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The storage module uses AWS SDK v2 and loads configuration from:
|
||||
- Environment variables (`AWS_REGION`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
|
||||
- Shared configuration files (`~/.aws/config`, `~/.aws/credentials`)
|
||||
- IAM roles (when running on AWS infrastructure)
|
||||
Reference in New Issue
Block a user