Flysystem v2 adapter for OpenStack Swift

v0.2.1 2021-12-30 22:06 UTC

This package is auto-updated.

Last update: 2022-01-01 09:20:25 UTC


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

A Flysystem v2 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