2025-12-31 21:56:05 +01:00
# storage
2026-01-08 14:09:14 +01:00
Standalone Go library for AWS S3 storage operations.
2025-12-31 21:56:05 +01:00
2026-01-08 14:09:14 +01:00
**Note: ** This is an independent library, not part of the Shiny ecosystem, though it is currently only used by Shiny services.
2025-12-31 21:56:05 +01:00
2026-01-08 14:09:14 +01:00
## Purpose
2025-12-31 21:56:05 +01:00
Provides standardized S3 object storage utilities with presigned URL generation. Used by services that need to store and serve files (PDFs, images, etc.).
2026-01-08 14:09:14 +01:00
## Usage
2025-12-31 21:56:05 +01:00
``` go
2026-01-09 13:43:53 +01:00
import "gitea.unbound.se/unboundsoftware/storage"
2025-12-31 21:56:05 +01:00
2026-01-08 14:09:14 +01:00
// Option 1: Managed uploads (multipart, 5MB part size) - loads AWS config automatically
2025-12-31 21:56:05 +01:00
s3Storage , err := storage . New ( "my-bucket" )
2026-01-08 14:09:14 +01:00
// Option 2: Direct uploads with custom AWS config
cfg , _ := config . LoadDefaultConfig ( context . Background ( ) )
s3Storage := storage . NewS3 ( cfg , "my-bucket" )
2025-12-31 21:56:05 +01:00
// Upload and get presigned URL (15-minute expiration)
url , err := s3Storage . Store ( "path/to/file.pdf" , reader , "application/pdf" )
```
2026-01-08 14:09:14 +01:00
## Features
2025-12-31 21:56:05 +01:00
2026-01-08 14:09:14 +01:00
- **Managed uploads** (`New` ) - Uses upload manager with 5MB multipart chunks for large files
- **Direct uploads** (`NewS3` ) - Uses PutObject directly, allows custom AWS config
2025-12-31 21:56:05 +01:00
- **Presigned URLs** - 15-minute expiration for secure access
2026-01-08 14:09:14 +01:00
## Configuration
2025-12-31 21:56:05 +01:00
Uses AWS SDK v2, loading config from:
- Environment variables (`AWS_REGION` , `AWS_ACCESS_KEY_ID` , `AWS_SECRET_ACCESS_KEY` )
- Shared config files (`~/.aws/config` , `~/.aws/credentials` )
- IAM roles (on AWS infrastructure)
2026-01-08 14:09:14 +01:00
## Development
- Go 1.23+
- Run tests: `go test ./...`