Flysystem v2 adapter for OpenStack Swift

v0.3.1 2022-12-15 11:09 UTC

This package is auto-updated.

Last update: 2023-03-16 19:59:37 UTC


Source code Software license GitHub issues Test status Psalm coverage Psalm level

A Flysystem v3 adapter for OpenStack Swift, using php-opencloud/openstack.

If you're looking for a Flysystem v1 adapter, see chrisnharvey/flysystem-openstack-swift.


$ composer require webalternatif/flysystem-openstack-swift


use League\Flysystem\Filesystem;
use OpenStack\OpenStack;
use Webf\Flysystem\OpenStackSwift\OpenStackSwiftAdapter;

$openstack = new OpenStack([
    'authUrl' => '{authUrl}',
    'region' => '{region}',
    'user' => [
        'id' => '{userId}',
        'password' => '{password}',
    'scope' => ['project' => ['id' => '{projectId}']],

$adapter = new OpenStackSwiftAdapter($openstack, '{containerName}');

$flysystem = new Filesystem($adapter);

Uploading large objects

In order to use the createLargeObject method of the underlying OpenStack library to upload large objects (which is mandatory for files over 5 GB), you must use the writeStream method and define the segment_size config option.

The segment_container option is also available if you want to upload segments in another container.


use Webf\Flysystem\OpenStackSwift\Config;

$flysystem->writeStream($path, $content, new Config([
    Config::OPTION_SEGMENT_SIZE => 52428800, // 50 MiB
    Config::OPTION_SEGMENT_CONTAINER => 'test_segments',


This library uses the FilesystemAdapterTestCase provided by league/flysystem-adapter-test-utilities, so it performs integration tests that need a real OpenStack Swift container.

To run tests, duplicate the phpunit.xml.dist file into phpunit.xml and fill all the environment variables, then run:

$ composer test

This will run Psalm and PHPUnit, but you can run them individually like this:

$ composer psalm
$ composer phpunit