Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GM's avatar
Level 8

using flysystem-aws-s3-v3 with another S3 system other than Amazon

My storage provider provides an S3 interface for storage. Is it possible to/how do I change AWS S3 driver so that it points to my storage provider rather than Amazon?

0 likes
4 replies
Indemnity83's avatar
Level 22

I just implemented this in a project the other day; just a note that some of the S3 compatible API's are V2, not V3 so you need flysystem/flysystem-aws-s3-v2.

You just create a service provider for the filesystem and have it build up the S3Client object with the parameters required. Here's what I built for connecting to DreamHost's system:

<?php

namespace App\Providers;

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v2\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
use Illuminate\Support\ServiceProvider;

class DreamStorageServiceProvider extends ServiceProvider
{
    const DREAM_BASE_URL = 'https://objects-us-west-1.dream.io';

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        Storage::extend('dream', function ($app, $config) {
            $config['base_url'] = isset($config['base_url']) ? $config['base_url'] : self::DREAM_BASE_URL;

            $client = S3Client::factory($config);

            return new Filesystem(new AwsS3Adapter($client, $config['bucket']));
        });
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
2 likes
Indemnity83's avatar

don't forget to add the config to your config\flysystem.php

        'dream' => [
            'driver' => 'dream',
            'key' => env('DREAM_KEY'),
            'secret' => env('DREAM_SECRET'),
            'bucket' => env('DREAM_BUCKET'),
        ],
robjbrain's avatar

@Indemnity83 i've tried to do the same however flysystem V2 requires aws/aws-sdk-php ~2.7 and V3 requires ^3.0.0 so the two are not compatible (you could not use dream and aws together in the same app for instance).

Did you find a way around this or just not encounter it?

Please or to participate in this conversation.