Store Media in an external Storage

Sulu is able to upload newly created media files directly to an external storage provider (such as AWS S3 or Google Cloud Storage).

AWS-S3

First install dependencies.

composer require league/flysystem league/flysystem-aws-s3-v3

Configure the storage with following yaml-snippet:

sulu_media:
    storage: s3
    storages:
        s3:
            key: 'your aws s3 key'
            secret: 'your aws s3 secret'
            bucket_name: 'your aws s3 bucket name'
            path_prefix: 'optional path prefix'
            region: 'eu-west-1'

If you use s3 compatible services (e.g. minio) you can pass additional arguments and endpoint to the configuration.

Google Cloud-Storage

First follow this the Google Cloud Documentation to setup a System-Account and download the json-key.

{
    "type": "service_account",
    "project_id": "project-id",
    "private_key_id": "some_number",
    "private_key": "-----BEGIN PRIVATE KEY-----\n....
    =\n-----END PRIVATE KEY-----\n",
    "client_email": "<api-name>[email protected]",
    "client_id": "...",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/...<api-name>api%40project-id.iam.gserviceaccount.com"
}

Install the dependencies:

composer require league/flysystem superbalist/flysystem-google-storage

Dump this file to a readable folder on your machine and configure the storage with following yaml-snippet:

sulu_media:
    storage: google_cloud
    storages:
        google_cloud:
            key_file_path: '/path/to/key.json'
            bucket_name: 'sulu-bucket'
            path_prefix: 'optional path prefix'