-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.php
45 lines (41 loc) · 1.48 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Created by PhpStorm.
* User: yidashi
* Date: 2017/2/16
* Time: 下午9:32
*/
namespace common\modules\attachment;
use yii\base\BootstrapInterface;
class Module extends \yii\base\Module implements BootstrapInterface
{
public function bootstrap($app)
{
$storage = [
'class' => 'common\modules\attachment\components\Storage',
'fs' => [
'class' => 'creocoder\flysystem\LocalFilesystem',
'path' => '@storagePath/upload',
],
'baseUrl' => '@storagePath/upload',
'imageProcessor' => 'common\modules\attachment\components\image\Local'
];
if (isset($this->params['filesystem_type'])) {
switch ($this->params['filesystem_type']) {
case 'qiniu':
$storage['fs'] = [
'class' => 'common\\modules\\attachment\\components\\flysystem\\QiniuFilesystem',
'access' => $this->params['qiniu_access_key'],
'secret' => $this->params['qiniu_access_secret'],
'bucket' => $this->params['qiniu_bucket'],
];
$storage['baseUrl'] = 'https://image.51siyuan.cn';
$storage['imageProcessor'] = [
'class' => 'common\\modules\\attachment\\components\\image\\Qiniu'
];
break;
}
}
$app->set('storage', $storage);
}
}