| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\librarys\storage\components;
- use app\librarys\storage\UploadFile;
- use app\librarys\storage\drivers\Local;
- use app\librarys\storage\drivers\BaseDriver;
- class StorageComponent extends \yii\base\Component
- {
- private $driver = null;
- protected $basePath;
- public function getDriver()
- {
- if ($this->driver === null) {
- $this->setDriver([
- 'class' => Local::class,
- ]);
- }
- return $this->driver;
- }
- public function setDriver($value)
- {
- if (is_array($value)) {
- $this->driver = \Yii::createObject($value);
- } else {
- $this->driver = $value;
- }
- }
- public function getBasePath()
- {
- return $this->basePath;
- }
- public function setBasePath($value)
- {
- $this->basePath = $value;
- }
- public function getUploadedFile($name)
- {
- if (substr($name, -1) === 's' || $name === 'xlsx'|| $name === 'crt' || $name === 'apk' || $name === 'pfx' || $name === 'cer' || $name === 'pem') {
- return UploadFile::getInstancesByStorage($name, $this->getDriver(), $this->basePath);
- }
- return UploadFile::getInstanceByStorage($name, $this->getDriver(), $this->basePath);
- }
- }
|