S3 storage
Object storage for Mladi Pirati projects on our self-hosted Garage instance.
File and object storage runs on our self-hosted Garage instance, which is S3-compatible:
https://s3.mladipirati.siGetting a bucket
Buckets and access keys are created on request. Submit a service access request with:
- Project name
- What will be stored (uploads, images, backups, …)
- Whether any files need to be publicly readable
You'll receive a bucket name and an access key pair scoped to that bucket.
Using it in code
Garage speaks the S3 API, so use the official AWS SDK with a custom endpoint:
import { S3Client } from '@aws-sdk/client-s3';
import { env } from '@/env';
export const s3 = new S3Client({
endpoint: 'https://s3.mladipirati.si',
region: 'garage',
forcePathStyle: true,
credentials: {
accessKeyId: env.S3_ACCESS_KEY_ID,
secretAccessKey: env.S3_SECRET_ACCESS_KEY,
},
});S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_BUCKET=Rules
- Keys only go in environment variables. Never commit them.
- Prefer presigned URLs for uploads, so files go straight to storage instead of through your server.
- Keep buckets private unless there's a clear reason to make files public.