Overview
Storage is configured inconfig/filesystems.php and controlled via environment variables. Each media type can use different storage disks, allowing you to:
- Store files locally during development
- Use S3 or S3-compatible services (DigitalOcean Spaces, Backblaze B2, etc.) in production
- Distribute files across multiple regions for better performance
Storage Disks
Default Disks
| Disk | Default Value | Purpose |
|---|---|---|
FILESYSTEM_DISK | local | Default filesystem disk |
VIDEO_DISK_DEFAULT | videos_local | Default video storage |
AUDIO_DISK_DEFAULT | audios_local | Default audio storage |
IMAGE_DISK | images_local | Image storage |
SCRIPT_DISK | scripts_local | Video script storage |
DUMP_DISK | dumps_local | Database dump storage |
Local Storage
Local storage is ideal for development and testing. Files are stored in thepublic/ directory.
Configuration
Set up local storage by specifying disk roots:storage/app/{type}.
Symbolic Links
Create symbolic links to make files publicly accessible:public/ to your storage directories:
public/videos→VIDEO_DISK_ROOTpublic/audios→AUDIO_DISK_ROOTpublic/images→IMAGE_DISK_ROOTpublic/dumps→DUMP_DISK_ROOTpublic/scripts→SCRIPT_DISK_ROOT
Local Disk Configuration
Fromconfig/filesystems.php:
S3 Storage
Use S3 or S3-compatible services for production deployments.Video Storage (S3)
Configure S3 storage for videos:Audio Storage (S3)
Configure S3 storage for audio:Image Storage (S3)
Configure S3 storage for images:Script Storage (S3)
Configure S3 storage for video encoding scripts:Dump Storage (S3)
Configure S3 storage for database dumps:S3 Configuration Options
| Option | Description |
|---|---|
ACCESS_KEY_ID | S3 access key |
SECRET_ACCESS_KEY | S3 secret key |
DEFAULT_REGION | S3 region (e.g., us-east-1) |
ENDPOINT | S3 endpoint URL |
BUCKET | S3 bucket name |
STREAM_READS | Enable streaming for large files |
DISABLE_ASSERTS | Disable S3 SDK assertions |
VISIBILITY | Default file visibility: public or private |
Multi-Disk Configuration
AnimeThemes supports using multiple disks for the same media type. This is useful for:- Geographic distribution: Serve files from the closest region
- Load balancing: Distribute traffic across multiple buckets
- Redundancy: Store copies in multiple locations
Example: Multiple Video Disks
- Use
videos_nycas the default for new uploads - Check both
videos_nycandvideos_frawhen retrieving files
Media URLs
Configure how media files are accessed:Subdomain URLs
Serve media from a dedicated subdomain:VIDEO_PATH and AUDIO_PATH empty when using subdomain URLs.
Path-based URLs
Serve media from a path on your main domain:VIDEO_URL and AUDIO_URL empty when using path-based URLs.
Media will be accessible at:
https://animethemes.moe/video/{file}https://animethemes.moe/audio/{file}
Streaming Methods
Response Streaming
Stream files through the application (default):- Works with any web server
- Allows access control and rate limiting
- Adds some overhead to the application server
Nginx Internal Redirect
Stream files directly from Nginx using internal redirects:- Reduces application server load
- Requires Nginx configuration
- May limit access control options
Storage Operations
Upload Files
Retrieve Files
Delete Files
CDN Configuration
Use a CDN for better performance and reduced bandwidth costs:- Enable CDN in the Spaces settings
- Copy the CDN endpoint URL
- Set it as the
IMAGE_URL,VIDEO_URL, orAUDIO_URL
- Create a distribution pointing to your S3 bucket
- Set the distribution URL as the media URL
Disk Space Management
Monitor Disk Usage
Clean Up Old Files
Implement a cleanup strategy for old or unused files:Troubleshooting
Files not accessible
-
Verify symbolic links exist:
-
Check file permissions:
-
Verify disk configuration in
config/filesystems.php
S3 connection errors
-
Verify credentials:
- Check endpoint and region settings
- Verify bucket permissions and CORS settings
Slow file uploads/downloads
- Enable
STREAM_READSfor large files - Use a CDN for downloads
- Consider multi-region deployment
- Increase PHP
upload_max_filesizeandpost_max_size
Next Steps
Environment Variables
Complete environment variable reference
Media Streaming
Learn about media streaming
Video API
Work with video files
Audio API
Work with audio files