Openstack / swift client for Yii2 Framework
Install with composer:
composer require raoptimus/yii2-openstack
Configuration
return [
//....
'components' =>
'swift' => [
'class' => raoptimus\openstack\Connection::class,
'authUrl' => 'https://somedomain.com:5000/v2.0',
'username' => '',
'apiKey' => '',
'tenant' => '',
'domain' => '',
'domainId' => '',
],
];
$swift = new raoptimus\openstack\Connection(
[
'class' => raoptimus\openstack\Connection::class,
'authUrl' => 'https://somedomain.com:5000/v2.0',
'username' => '',
'apiKey' => '',
'tenant' => '',
'domain' => '',
'domainId' => '',
]
);
$container = $swift->getContainer('name of container');
Use connection
$swift = \Yii::$app->get('swift');
$container = $swift->getContainer('name of container');
Push file to swift storage
$container->pushObject($source, $target);
Pull file from swift storage
$container->pullObject($source, $target);
Get stat of file from swift storage
$container->getObject($filename);
Exists file in swift storage
$container->existsObject($filename);
Delete file from swift storage
$container->deleteObject($filename);