Quellcode durchsuchen

feat: 添加配置文件 添加京东云驱动

Gosowong vor 2 Jahren
Ursprung
Commit
1e1d24a086
2 geänderte Dateien mit 205 neuen und 0 gelöschten Zeilen
  1. 15 0
      crmeb/config/upload.php
  2. 190 0
      crmeb/crmeb/services/upload/storage/Jdoss.php

+ 15 - 0
crmeb/config/upload.php

@@ -57,5 +57,20 @@ return [
             'AccessKeySecret' => '', //sys_config('tengxun_secretKey')
             'APPID' => '', //sys_config('tengxun_appid')
         ],
+        //oss 京东云
+        'jdoss' => [
+            'AccessKeyId' => '', // sys_config('accessKey')
+            'AccessKeySecret' => '', // sys_config('secretKey')
+        ],
+        //oss 华为云
+        'obs' => [
+            'AccessKeyId' => '', // sys_config('accessKey')
+            'AccessKeySecret' => '', // sys_config('secretKey')
+        ],
+        //oss 天翼云
+        'tyoss' => [
+            'AccessKeyId' => '', // sys_config('accessKey')
+            'AccessKeySecret' => '', // sys_config('secretKey')
+        ],
     ]
 ];

+ 190 - 0
crmeb/crmeb/services/upload/storage/Jdoss.php

@@ -0,0 +1,190 @@
+<?php
+
+namespace crmeb\services\upload\storage;
+
+use crmeb\services\upload\BaseUpload;
+use crmeb\services\upload\extend\jdoss\Client as CrmebClient;
+
+class Jdoss extends BaseUpload
+{
+
+
+    /**
+     * 应用id
+     * @var string
+     */
+    protected $appid;
+
+    /**
+     * accessKey
+     * @var mixed
+     */
+    protected $accessKey;
+
+    /**
+     * secretKey
+     * @var mixed
+     */
+    protected $secretKey;
+
+    /**
+     * 句柄
+     * @var CrmebClient
+     */
+    protected $handle;
+
+    /**
+     * 空间域名 Domain
+     * @var mixed
+     */
+    protected $uploadUrl;
+
+    /**
+     * 存储空间名称  公开空间
+     * @var mixed
+     */
+    protected $storageName;
+
+    /**
+     * COS使用  所属地域
+     * @var mixed|null
+     */
+    protected $storageRegion;
+
+    /**
+     * @var string
+     */
+    protected $cdn;
+
+    /**
+     * 水印位置
+     * @var string[]
+     */
+    protected $position = [
+        '1' => 'northwest',//:左上
+        '2' => 'north',//:中上
+        '3' => 'northeast',//:右上
+        '4' => 'west',//:左中
+        '5' => 'center',//:中部
+        '6' => 'east',//:右中
+        '7' => 'southwest',//:左下
+        '8' => 'south',//:中下
+        '9' => 'southeast',//:右下
+    ];
+
+    /**
+     * 初始化
+     * @param array $config
+     * @return mixed|void
+     */
+    public function initialize(array $config)
+    {
+        parent::initialize($config);
+        $this->accessKey = $config['accessKey'] ?? null;
+        $this->secretKey = $config['secretKey'] ?? null;
+        $this->uploadUrl = $this->checkUploadUrl($config['uploadUrl'] ?? '');
+        $this->storageName = $config['storageName'] ?? null;
+        $this->storageRegion = $config['storageRegion'] ?? null;
+        $this->cdn = $config['cdn'] ?? null;
+        $this->waterConfig['watermark_text_font'] = 'simfang仿宋.ttf';
+    }
+
+    /**
+     * 实例化cos
+     * @return CrmebClient
+     */
+    protected function app()
+    {
+        $this->handle = new CrmebClient([
+            'accessKey' => $this->accessKey,
+            'secretKey' => $this->secretKey,
+            'region' => $this->storageRegion,
+            'bucket' => $this->storageName,
+            'uploadUrl' => $this->uploadUrl
+        ]);
+        return $this->handle;
+    }
+
+    public function move(string $file = 'file')
+    {
+        // TODO: Implement move() method.
+    }
+
+    public function stream($fileContent, string $key = null)
+    {
+        // TODO: Implement stream() method.
+    }
+
+    public function delete(string $filePath)
+    {
+        // TODO: Implement delete() method.
+    }
+
+
+    public function listbuckets(string $region, bool $line = false, bool $shared = false)
+    {
+        try {
+            $res = $this->app()->listBuckets();
+            return $res['Buckets']['Bucket'] ?? [];
+        } catch (\Throwable $e) {
+            return [];
+        }
+    }
+
+    public function createBucket(string $name, string $region)
+    {
+        // TODO: Implement createBucket() method.
+    }
+
+    public function getRegion()
+    {
+        return [
+            [
+                'value' => 'cn-north-1',
+                'label' => '华北-北京'
+            ],
+            [
+                'value' => 'cn-east-1',
+                'label' => '华东-宿迁'
+            ],
+            [
+                'value' => 'cn-east-2',
+                'label' => '华东-上海'
+            ],
+            [
+                'value' => 'cn-south-1',
+                'label' => '华南-广州'
+            ]
+        ];
+    }
+
+    public function deleteBucket(string $name)
+    {
+        // TODO: Implement deleteBucket() method.
+    }
+
+    public function bindDomian(string $name, string $domain, string $region = null)
+    {
+        // TODO: Implement bindDomian() method.
+    }
+
+    public function setBucketCors(string $name, string $region)
+    {
+        // TODO: Implement setBucketCors() method.
+    }
+
+    public function getTempKeys()
+    {
+        // TODO: Implement getTempKeys() method.
+    }
+
+    public function thumb(string $filePath = '')
+    {
+        // TODO: Implement thumb() method.
+    }
+
+    public function water(string $filePath = '')
+    {
+        // TODO: Implement water() method.
+    }
+}