Overview
The Google Cloud Storage (GCS) client enables automatic upload of recorded streams, VOD files, and preview images to Google Cloud Platform storage buckets.Features
GCP Integration
Native integration with Google Cloud Platform
Automatic Upload
Seamless upload of recordings to GCS buckets
Simple Setup
Easy configuration using default credentials
File Management
Upload, delete, and check file existence
Configuration
Spring Bean Configuration
Add the GCS storage client bean to your application’sred5-web.xml:
Authentication: GCS uses Application Default Credentials (ADC). No need to configure access keys explicitly.
Configuration Parameters
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
enabled | boolean | Enable GCS storage integration | Yes | false |
storageName | string | GCS bucket name | Yes | - |
cacheControl | string | Cache-Control header value | No | no-store, no-cache, must-revalidate, max-age=0 |
Authentication Setup
Application Default Credentials (ADC)
Google Cloud Storage uses Application Default Credentials. Set up authentication using one of these methods:Option 1: Service Account Key (Development)
Create Service Account
In Google Cloud Console, go to IAM & Admin > Service Accounts and create a new service account.
Option 2: Compute Engine Service Account (Production)
Attach Service Account
When creating your GCE instance, attach a service account with Storage permissions.
Option 3: Google Kubernetes Engine (GKE)
Use Workload Identity to authenticate from GKE:Required IAM Roles
Recommended Role
The simplest approach is to use the Storage Object Admin role:Custom Role (Least Privilege)
For better security, create a custom role with minimal permissions:storage.objects.create- Upload filesstorage.objects.delete- Delete filesstorage.objects.get- Check existence and retrieve filesstorage.objects.list- List objects (for future features)
GCS Bucket Setup
Create a Bucket
Configure Bucket Permissions
For public access to uploaded files:Bucket Lifecycle Policy (Optional)
Createlifecycle.json to automatically transition or delete old files:
Storage Classes
GCS offers multiple storage classes for cost optimization:| Class | Use Case | Availability |
|---|---|---|
| Standard | Frequently accessed data | >99.99% |
| Nearline | Access < once per month | 99.95% |
| Coldline | Access < once per quarter | 99.95% |
| Archive | Long-term archive, < once per year | 99.95% |
Storage Class: The current GCS client implementation doesn’t support setting storage class during upload. Use bucket default storage class or lifecycle policies.
File Operations
Upload Files
Delete Files
Check File Existence
Retrieve Files
The baseget() method is not currently implemented in the GCS client. To retrieve files, use the GCS API directly:
Complete Configuration Example
red5-web.xml
Environment Setup
Add to/usr/local/antmedia/antmedia startup script:
/etc/environment:
Troubleshooting
Authentication errors
Authentication errors
Symptoms:
401 Unauthorized or 403 Forbidden errorsSolutions:- Verify
GOOGLE_APPLICATION_CREDENTIALSis set correctly - Check service account has necessary permissions
- Ensure service account key file is readable
- Verify project ID in credentials matches bucket project
Bucket not found
Bucket not found
Symptoms:
404 Not Found errorsSolutions:- Verify bucket name in
storageNameis correct (case-sensitive) - Check bucket exists:
gsutil ls gs://your-bucket-name/ - Ensure service account has access to the bucket
Files not uploading
Files not uploading
Symptoms: No errors but files don’t appear in GCSSolutions:
- Confirm
enabledis set totrue - Check application logs for errors
- Verify network connectivity to
storage.googleapis.com - Test with a small file first
Slow uploads
Slow uploads
Symptoms: Uploads take longer than expectedSolutions:
- Check network bandwidth and latency
- Choose a bucket region closer to your server
- Consider using Google Cloud CDN for distribution
- Monitor GCS quotas and limits
Implementation Differences
vs AWS S3
Key differences from the S3 implementation:| Feature | S3 | GCS |
|---|---|---|
| Authentication | Access/Secret keys or IAM | Application Default Credentials |
| Multipart Upload | Yes, automatic >5MB | Handled by client library |
| Storage Classes | Configurable per upload | Bucket default or lifecycle |
| Permissions/ACL | Configurable (8 options) | Managed via IAM |
| Bulk Delete | Supported with regex | Not implemented |
| Progress Tracking | Full support | Basic support |
| Retrieve Files | Implemented | Not implemented |
Current Limitations
Advanced Usage
Custom Metadata
To add custom metadata to uploaded files, you’ll need to extend theGCPStorageClient class:
Monitoring and Logging
Enable detailed logging for GCS operations:Security Best Practices
Use VPC Service Controls
For sensitive data, use VPC Service Controls to restrict data exfiltration.
Performance Optimization
Regional Colocation
Place your GCS bucket in the same region as your Ant Media Server:Network Optimization
- Use Google Cloud VPC for private Google API access
- Configure Private Google Access for subnet
- Consider Cloud CDN for content delivery
Cost Optimization
- Use lifecycle policies to transition old recordings to Nearline/Coldline
- Set up object versioning with lifecycle deletion
- Monitor storage costs in Cloud Billing
Configuration File Location:
red5-web.xml is typically located at /usr/local/antmedia/webapps/YourApp/WEB-INF/red5-web.xml