bigdropinc / yii2-cloudstorage
Common interface for amazon s3 and rackspace cloud files
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: >=2.0.6
Requires (Dev)
- aws/aws-sdk-php: 2.5.2
- phpunit/phpunit: 4.8.24
- rackspace/php-opencloud: ~1.16
This package is not auto-updated.
Last update: 2024-11-13 20:13:23 UTC
README
Common interface for amazon s3 and rackspace cloud files.
Configuration
Amazon S3
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/' ], ], ];
Rackspace Cloud Files
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/' ], ], ];
Usage
Uploading Files
$file = '@frontend/web/media/image.png'; Yii::$app->cloudStorage->upload($file);
Downloading Files
$name = 'media/image.png'; $dir = '@frontend/web/tmp'; Yii::$app->cloudStorage->download($name, $dir);
Deleting Files
$name = 'media/image.png'; Yii::$app->cloudStorage->delete($name);
Getting Public Url
$name = 'media/image.png'; Yii::$app->cloudStorage->getPublicUrl($name);