浏览代码

cos token有效期延长

waymen 4 月之前
父节点
当前提交
6fe67f6260

+ 3 - 3
app/Libraries/BIM/Glendale/Client.php

@@ -43,14 +43,14 @@ class Client
 
     public function request(string $method, string $uri, array $options = []): ?array
     {
-        Log::debug('send to glendale engine url: ' . $uri);
-        Log::debug('send to glendale engine input: ', $options);
-
         return $this->parseResponse($this->client->request($method, $uri, $options));
     }
 
     public function post(string $uri, array $options = [])
     {
+        Log::debug('send to glendale engine url: ' . $uri);
+        Log::debug('send to glendale engine input: ', $options);
+        
         return $this->request("POST", $uri, $options);
     }
 

+ 13 - 7
app/Libraries/BIM/Glendale/Glendale.php

@@ -80,7 +80,7 @@ class Glendale extends BIMAbstract
         if (!empty($append)) {
             $input = array_merge($input, $append);
         }
-        
+
         return [
             'input' => json_encode($input)
         ];
@@ -322,17 +322,23 @@ class Glendale extends BIMAbstract
      */
     public function getModel3DViews(string $lightweightName): array
     {
+        $result = [];
+
         if (empty($lightweightName)) {
-            return [];
+            return $result;
         }
 
-        $res = Client::getInstance()->get('/api/app/model/model3DViews', [
-            'LightweightName' => $lightweightName
-        ]);
+        try {
+            $res = Client::getInstance()->get('/api/app/model/model3DViews', [
+                'LightweightName' => $lightweightName
+            ]);
 
-        foreach ($res['datas'] as $data) {
-            $result[] = $this->replaceUrlToHttps($data, ['accessAddress']);
+            foreach ($res['datas'] as $data) {
+                $result[] = $this->replaceUrlToHttps($data, ['accessAddress']);
+            }
+        } catch (\Throwable $th) {
         }
+
         return $result;
     }
 

+ 4 - 2
app/Libraries/ChunkedUpload/Disks/Cos.php

@@ -69,14 +69,16 @@ class Cos implements ChunkedUploadContact
 
         $bucket = $cosConfig['bucket'] . '-' . $cosConfig['app_id'];
 
+        $prefixArr = explode('/', $pathPrefix);
+
         $config = [
             'url' => 'https://sts.tencentcloudapi.com/',
             'secretId' => $cosConfig['secret_id'],
             'secretKey' => $cosConfig['secret_key'],
             'bucket' => $bucket,
             'region' => $cosConfig['region'],
-            'durationSeconds' => 60, // 密钥有效期(秒)
-            'allowPrefix' => [$pathPrefix . '/*'], // 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径,例子: a.jpg 或者 a/* 或者 * (使用通配符*存在重大安全风险, 请谨慎评估使用)
+            'durationSeconds' => 600, // 密钥有效期(秒)
+            'allowPrefix' => [($prefixArr[0] ?? '') . '/*'], // 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径,例子: a.jpg 或者 a/* 或者 * (使用通配符*存在重大安全风险, 请谨慎评估使用)
             // 密钥的权限列表。简单上传和分片需要以下的权限,其他权限列表请看 https://cloud.tencent.com/document/product/436/31923
             'allowActions' => [
                 // 简单上传