PHP code example of nimbusoft / flysystem-openstack-swift

1. Go to this page and download the library: Download nimbusoft/flysystem-openstack-swift library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nimbusoft / flysystem-openstack-swift example snippets


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

$container = $openstack->objectStoreV1()
    ->getContainer('{containerName}');

$adapter = new Nimbusoft\Flysystem\OpenStack\SwiftAdapter($container);

$flysystem = new League\Flysystem\Filesystem($adapter);

$flysystem = new League\Flysystem\Filesystem($adapter, new \League\Flysystem\Config([
    'swiftLargeObjectThreshold' => 104857600, // 100 MiB
    'swiftSegmentSize' => 52428800, // 50 MiB
    'swiftSegmentContainer' => 'mySegmentContainer',
]));

$flysystem->write($path, $contents, new \League\Flysystem\Config([
    'swiftLargeObjectThreshold' => 52428800, // 50 MiB
    'contentType' => 'text/plain',
    'deleteAfter' => 3600, // 1 hour
])