Common interface for amazon s3 and rackspace cloud files.
Once the extension is installed, simply modify your application configuration as follows:
return [
//...
'components' => [
//...
'cloudStorage' => [
'class' => 'bigdropinc\cloudStorage\AmazonS3',
'key' => '***',
'secret' => '***',
'bucket' => 'bucket name',
//fill this attribute, if you know the base url of your bucket
'cloudStorageBaseUrl' => 'http://site.s3.amazon.com/'
],
],
];
Once the extension is installed, simply modify your application configuration as follows:
return [
//...
'components' => [
//...
'cloudStorage' => [
'class' => 'bigdropinc\cloudStorage\RackspaceCloudFiles',
'username' => '***',
'apiKey' => '***',
'region' => 'LON',
'containerName' => 'container name',
//fill this attribute, if you know the base url of your container
'cloudStorageBaseUrl' => 'http://site.rackspace.com/'
],
],
];
$file = '@frontend/web/media/image.png';
Yii::$app->cloudStorage->upload($file);
$name = 'media/image.png';
$dir = '@frontend/web/tmp';
Yii::$app->cloudStorage->download($name, $dir);
$name = 'media/image.png';
Yii::$app->cloudStorage->delete($name);
$name = 'media/image.png';
Yii::$app->cloudStorage->getPublicUrl($name);