Skip to main content

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’s red5-web.xml:
Authentication: GCS uses Application Default Credentials (ADC). No need to configure access keys explicitly.

Configuration Parameters

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)

1

Create Service Account

In Google Cloud Console, go to IAM & Admin > Service Accounts and create a new service account.
2

Download Key File

Create and download a JSON key file for the service account.
3

Set Environment Variable

Set the GOOGLE_APPLICATION_CREDENTIALS environment variable:
4

Restart Ant Media Server

Restart the server to pick up the new credentials.

Option 2: Compute Engine Service Account (Production)

1

Attach Service Account

When creating your GCE instance, attach a service account with Storage permissions.
2

Configure Permissions

Ensure the service account has the necessary roles (see below).
3

No Additional Setup

No environment variables needed - credentials are automatically available.

Option 3: Google Kubernetes Engine (GKE)

Use Workload Identity to authenticate from GKE:

Required IAM Roles

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:
Required permissions:
  • storage.objects.create - Upload files
  • storage.objects.delete - Delete files
  • storage.objects.get - Check existence and retrieve files
  • storage.objects.list - List objects (for future features)

GCS Bucket Setup

Create a Bucket

Configure Bucket Permissions

For public access to uploaded files:
For private files, skip the public access configuration.

Bucket Lifecycle Policy (Optional)

Create lifecycle.json to automatically transition or delete old files:

Storage Classes

GCS offers multiple storage classes for cost optimization:
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

Not Implemented: Bulk delete (deleteMultipleFiles) is not currently implemented for GCS. Use single delete operations or implement custom logic.

Check File Existence

Retrieve Files

The base get() 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:
Or set system-wide in /etc/environment:

Troubleshooting

Symptoms: 401 Unauthorized or 403 Forbidden errorsSolutions:
  • Verify GOOGLE_APPLICATION_CREDENTIALS is set correctly
  • Check service account has necessary permissions
  • Ensure service account key file is readable
  • Verify project ID in credentials matches bucket project
Symptoms: 404 Not Found errorsSolutions:
  • Verify bucket name in storageName is correct (case-sensitive)
  • Check bucket exists: gsutil ls gs://your-bucket-name/
  • Ensure service account has access to the bucket
Symptoms: No errors but files don’t appear in GCSSolutions:
  • Confirm enabled is set to true
  • Check application logs for errors
  • Verify network connectivity to storage.googleapis.com
  • Test with a small file first
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:

Current Limitations

The GCS implementation has some limitations compared to S3:
  • deleteMultipleFiles() throws UnsupportedOperationException
  • get() method is not implemented (returns null)
  • No storage class configuration per upload
  • No ACL configuration per upload

Advanced Usage

Custom Metadata

To add custom metadata to uploaded files, you’ll need to extend the GCPStorageClient class:

Monitoring and Logging

Enable detailed logging for GCS operations:

Security Best Practices

1

Use Service Accounts

Always use service accounts, never personal user credentials.
2

Principle of Least Privilege

Grant only required permissions (objectAdmin or custom role).
3

Rotate Keys Regularly

If using key files, rotate them every 90 days.
4

Secure Key Storage

Store service account keys securely with restricted file permissions:
5

Use VPC Service Controls

For sensitive data, use VPC Service Controls to restrict data exfiltration.
6

Enable Audit Logging

Enable Cloud Audit Logs to track all storage access.

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