render($this->action->id); } public function actionGetOssConfig() { $mall_id = $this->mall_id; // $mall_id = 5; $config = \Yii::$app->services->attachment->getStorageConfig($mall_id); $data = [ 'is_show_long_vide' => 1, // 'config' => $config, ]; // if ($config['dirve'] == Attachment::DRIVE_LOCAL) $data['is_show_long_vide'] = 0; switch ($config['drive']) { //本地上传 case Attachment::DRIVE_LOCAL: $data['is_show_long_vide'] = 0; break; //七牛云 case Attachment::DRIVE_QINIU: //获取token $qiniu_auto = new QiniuAuto($config['access_key_id'], $config['access_key_secret']); $qiniu_token = $qiniu_auto->uploadToken($config['bucket']); $data['token'] = $qiniu_token; $data['bucket'] = $config['bucket']; $data['domain'] = $config['domain']; $data['secret_id'] = $config['access_key_id']; $data['secret_key'] = $config['access_key_secret']; break; //腾讯云 case Attachment::DRIVE_COS: $data['bucket'] = $config['bucket']; $data['area'] = $config['area']; $data['domain'] = $config['domain']; $data['secret_id'] = $config['secret_id']; $data['secret_key'] = $config['secret_key']; break; //阿里云 case Attachment::DRIVE_OSS: $arr = explode('.', $config['storage_aliyun_endpoint']); $data['bucket'] = $config['storage_aliyun_bucket']; // $data['area'] = $config['area']; $data['region'] = $arr[0]; $data['domain'] = $config['storage_aliyun_user_url']; $data['endpoint'] = $config['storage_aliyun_endpoint']; $data['protocols'] = $config['storage_aliyun_transport_protocols']; if (!empty($config['arn'])) { $sts_config = (new AliyunStsServices())->getSts($mall_id, $config); $data['security_token'] = $sts_config['SecurityToken']; $data['secret_id'] = $sts_config['AccessKeyId']; $data['secret_key'] = $sts_config['AccessKeySecret']; } else { $data['is_show_long_vide'] = 0; } break; } $data['drive'] = $config['drive']; return $this->success('获取成功', $data); } public function actionSetLongVideoData() { $mall = Yii::$app->session->get('mall'); $mall_id = !empty($mall) ? $mall['id'] : 0; $post = Yii::$app->request->post(); try { Yii::$app->services->attachment->setLongVideoData($mall_id, $post); } catch (\Exception $e) { return $this->error($e->getMessage()); } return $this->success('操作成功'); } }