Files
storage/README.md
T
argoyleandClaude Opus 5.5 c225556976
storage / test (pull_request) Successful in 47s
storage / vulnerabilities (pull_request) Successful in 59s
pre-commit / pre-commit (pull_request) Successful in 4m55s
feat: move module path to git.unbound.se
The module is now git.unbound.se/unboundsoftware/storage. The API is unchanged. Tags up to v0.4.4 declare gitea.unbound.se/unboundsoftware/storage and stay resolvable through that alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kko4x3MYEcWMMdkx12WpBa
2026-10-17 19:55:00 +02:00

1.4 KiB

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

import "git.unbound.se/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)

import (
    "github.com/aws/aws-sdk-go-v2/config"
    "git.unbound.se/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)