yiizh / yii2-storage
The storage extension for Yii2.
Installs: 20 538
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
This package is auto-updated.
Last update: 2024-10-26 14:49:38 UTC
README
This extension provides support for multi storage.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiizh/yii2-storage "dev-master"
or add
"yiizh/yii2-storage": "*"
to the require section of your composer.json
file.
Usage
Change config file :
Config
For local storage
... 'components' => [ 'storage' => [ 'class'=>'\yiizh\storage\LocalStorage', 'basePath' => '@app/web/uploads' ] ] ...
For Aliyun storage
... 'components' => [ 'storage' => [ 'class' => '\yiizh\storage\AliyunStorage', 'accessKey' => '<您从OSS获得的AccessKeyId>', 'accessSecret' => '<您从OSS获得的AccessKeySecret>', 'endpoint' => '<您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com>', 'bucket' => '<您的绑定在某个Bucket上的自定义域名>', ] ] ...
Upload File
\Yii::$app->storage->save('文件名', '文件内容');