Overview
When storage is configured, BioAgents uses presigned URLs for direct client-to-S3 uploads, eliminating the need to proxy files through your server.If storage is not configured, file upload features will be disabled.
Supported Providers
Amazon S3
AWS S3 buckets
DigitalOcean Spaces
S3-compatible object storage
MinIO
Self-hosted S3-compatible storage
Cloudflare R2
S3-compatible with zero egress fees
Quick Start
Environment Variables
Storage provider to use.Options:
s3- Use S3-compatible storage- Empty or not set - Storage disabled
AWS Credentials
S3 access key ID.Alternative:
S3_ACCESS_KEY_IDS3 secret access key.Alternative:
S3_SECRET_ACCESS_KEYS3 region.Alternative:
S3_REGIONS3 bucket name.
Custom S3 endpoint for S3-compatible services.Examples:
- DigitalOcean Spaces:
https://nyc3.digitaloceanspaces.com - MinIO:
http://localhost:9000 - Cloudflare R2:
https://your-account.r2.cloudflarestorage.com
You can use either
AWS_* or S3_* variants for credentials. Both are equivalent.Provider Setup Guides
Amazon S3
Amazon S3
Create S3 Bucket
- Open AWS S3 Console
- Click “Create bucket”
- Enter bucket name and select region
- Configure CORS (see below)
Create IAM User
- Open IAM Console
- Create new user with programmatic access
- Attach policy with S3 permissions (see below)
- Save access key ID and secret access key
DigitalOcean Spaces
DigitalOcean Spaces
Create Space
- Open DigitalOcean Spaces
- Click “Create Space”
- Select region and name
- Configure CORS (see below)
MinIO (Self-Hosted)
MinIO (Self-Hosted)
Create Bucket
- Open MinIO Console at http://localhost:9001
- Login with
minioadmin/minioadmin - Create new bucket
- Configure CORS in bucket settings
Cloudflare R2
Cloudflare R2
Create R2 Bucket
- Open Cloudflare Dashboard
- Go to R2 Object Storage
- Create new bucket
- Configure CORS (see below)
Generate API Token
- Go to R2 > Manage R2 API Tokens
- Create API token with R2 permissions
- Save access key ID and secret access key
CORS Configuration
For direct client-to-S3 uploads, you must configure CORS on your S3 bucket.IAM Policy (AWS S3)
Minimum required permissions for S3:File Organization
BioAgents organizes files in S3 with the following structure:Implementation Details
Storage Provider Interface
TheStorageProvider abstract class defines the storage interface:
src/storage/types.ts
S3 Provider Implementation
The S3 provider uses AWS SDK v3:src/storage/providers/s3.ts
Presigned URL Generation
For secure direct uploads:src/storage/providers/s3.ts
Storage Configuration Loading
src/storage/config.ts
Upload Flow
BioAgents uses presigned URLs for efficient file uploads:File Size Limits
Presigned URLs enforce file size limits to prevent abuse:Troubleshooting
CORS Errors
CORS Errors
Symptom:
No 'Access-Control-Allow-Origin' header errorsSolutions:- Configure CORS on your S3 bucket (see above)
- Verify allowed origins match your frontend URL
- Check browser console for specific CORS error
Access Denied
Access Denied
Symptom:
AccessDenied or 403 Forbidden errorsSolutions:- Verify IAM policy grants required permissions
- Check bucket policy doesn’t deny access
- Ensure credentials are correct and not expired
Invalid Credentials
Invalid Credentials
Symptom:
InvalidAccessKeyId or SignatureDoesNotMatch errorsSolutions:- Double-check
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY - Ensure no extra spaces or newlines in credentials
- Verify credentials are for the correct account
Bucket Not Found
Bucket Not Found
Symptom:
NoSuchBucket errorSolutions:- Verify bucket name is correct (case-sensitive)
- Check bucket region matches
AWS_REGION - For S3-compatible services, verify
S3_ENDPOINTis correct
Upload Size Mismatch
Upload Size Mismatch
Symptom: Upload fails with size errorSolutions:
- Ensure file size passed to presigned URL matches actual upload
- Don’t modify file after getting presigned URL
- Check network didn’t truncate upload
Security Best Practices
Use Short-Lived Presigned URLs
Use Short-Lived Presigned URLs
Default expiration is 1 hour. Reduce for sensitive files:
Enforce File Size Limits
Enforce File Size Limits
Always pass
contentLength to prevent abuse:Validate Content Types
Validate Content Types
Check file MIME types before generating presigned URLs:
Use IAM Least Privilege
Use IAM Least Privilege
Grant only required S3 permissions (see IAM policy above).
Next Steps
Environment Variables
View all configuration options
Authentication
Configure JWT or payment-based auth