Skip to content

Latest commit

 

History

History
207 lines (161 loc) · 5.48 KB

File metadata and controls

207 lines (161 loc) · 5.48 KB

Cloud storage providers

One of the core feature of Flysystem is its ability to interact easily with remote filesystems, including many cloud storage providers. This bundle provides the same level of support for these cloud providers by providing corresponding adapters in the configuration.

Azure

Installation

composer require league/flysystem-azure-blob-storage

Usage

# config/packages/flysystem.yaml

flysystem:
    storages:
        users.storage:
            adapter: 'azure'
            options:
                client: 'azure_client_service' # The service ID of the MicrosoftAzure\Storage\Blob\BlobRestProxy instance
                container: 'container_name'
                prefix: 'optional/path/prefix'

AsyncAws S3

Installation

composer require league/flysystem-async-aws-s3

Usage

# config/packages/flysystem.yaml

flysystem:
    storages:
        users.storage:
            adapter: 'asyncaws'
            options:
                client: 'aws_client_service' # The service ID of the AsyncAws\S3\S3Client instance
                bucket: 'bucket_name'
                prefix: 'optional/path/prefix'

AWS SDK S3

Installation

composer require league/flysystem-aws-s3-v3

Usage

# config/packages/flysystem.yaml

flysystem:
    storages:
        users.storage:
            adapter: 'aws'
            # visibility: public # Make the uploaded file publicly accessible in S3
            options:
                client: 'aws_client_service' # The service ID of the Aws\S3\S3Client instance
                bucket: 'bucket_name'
                prefix: 'optional/path/prefix'
                streamReads: true

Google Cloud Storage

Installation

composer require league/flysystem-google-cloud-storage

Usage

# config/packages/flysystem.yaml
 
flysystem:
    storages:
        users.storage:
            adapter: 'gcloud'
            options:
                client: 'gcloud_client_service' # The service ID of the Google\Cloud\Storage\StorageClient instance
                bucket: 'bucket_name'
                prefix: 'optional/path/prefix'
                streamReads: false

DigitalOcean Spaces

The DigitalOcean Spaces are compatible with the AWS S3 API, meaning that you can use the same configuration as for a AWS storage. For example:

# config/packages/flysystem.yaml

services:
    digitalocean_spaces_client:
        class: 'AsyncAws\S3\S3Client'
        arguments:
            -
                endpoint: '%env(DIGITALOCEAN_SPACES_ENDPOINT)%'
                accessKeyId: '%env(DIGITALOCEAN_SPACES_ID)%'
                accessKeySecret: '%env(DIGITALOCEAN_SPACES_SECRET)%'

flysystem:
    storages:
        cdn.storage:
            adapter: 'asyncaws'
            options:
                client: 'digitalocean_spaces_client'
                bucket: '%env(DIGITALOCEAN_SPACES_BUCKET)%'

Scaleway Object Storage

The Scaleway Object Storage is compatible with the AWS S3 API, meaning that you can use the same configuration as for a AWS storage. For example:

# config/packages/flysystem.yaml

services:
    scaleway_spaces_client:
        class: 'AsyncAws\S3\S3Client'
        arguments:
            -   
                endpoint: '%env(SCALEWAY_SPACES_ENDPOINT)%'
                accessKeyId: '%env(SCALEWAY_SPACES_ID)%'
                accessKeySecret: '%env(SCALEWAY_SPACES_SECRET)%'

flysystem:
    storages:
        cdn.storage:
            adapter: 'asyncaws'
            options:
                client: 'scaleway_spaces_client'
                bucket: '%env(SCALEWAY_SPACES_BUCKET)%'

Cloudflare R2

The Cloudflare R2 is compatible with the AWS S3 API, meaning that you can use the same configuration as for an AWS storage. Both the regular and the async AWS Client can be used. As example:

# config/packages/flysystem.yaml

services:
    cloudflare_r2_client:
        class: 'AsyncAws\S3\S3Client'
        arguments:
            -   
                endpoint: '%env(CLOUDFLARE_R2_ENDPOINT)%'
                accessKeyId: '%env(CLOUDFLARE_R2_ID)%'
                accessKeySecret: '%env(CLOUDFLARE_R2_SECRET)%'

flysystem:
    storages:
        cdn.storage:
            adapter: 'asyncaws'
            options:
                client: 'cloudflare_r2_client'
                bucket: '%env(CLOUDFLARE_R2_BUCKET)%'

Cloudflare R2 does not have implemented ACL-related features yet, and thereby making use of Flysystem's move and copy methods requires configuring explicit value for visibility and setting retain_visibility to false to prevent the S3 adapter to call the GetObjectAcl command to retrieve an object's current ACL visibility, then resulting in an exception.

flysystem:
    storages:
        cdn.storage:
            # ...
            visibility: private # or public
            
            # to use the visibility as defined above instead of retaining the object's visibility, and not having to run
            # the unsupported `GetObjectAcl` command to get the object's current visibility.
            retain_visibility: false  
            # ...

Next

Interacting with FTP and SFTP servers