Browse Source

客户&人员

cqp 11 tháng trước cách đây
mục cha
commit
3439a1015d
2 tập tin đã thay đổi với 6 bổ sung5 xóa
  1. 2 2
      app/Service/FileUploadService.php
  2. 4 3
      app/Service/OssService.php

+ 2 - 2
app/Service/FileUploadService.php

@@ -77,7 +77,7 @@ class FileUploadService extends Service
     }
 
     //获取文件的位置oss
-    public function getFileShow($file_name){
+    public function getFileShow($file_name,$expired = 3500){
         $path = "";
         if(empty($file_name)) return $path;
 
@@ -87,7 +87,7 @@ class FileUploadService extends Service
             $date = \DateTime::createFromFormat('Ymd', $timestamp);
             $date = $date->format('Y-m-d');
             $savePath = self::string3 . $date . '/' . $file_name;
-            list($status,$path) = (new OssService())->getTemporaryUrl($savePath);
+            list($status,$path) = (new OssService())->getTemporaryUrl($savePath,$expired);
         }
 
         return $path;

+ 4 - 3
app/Service/OssService.php

@@ -73,7 +73,7 @@ class OssService extends Service
     }
 
     //生成临时文件
-    public function getTemporaryUrl($objectKey)
+    public function getTemporaryUrl($objectKey, $expired = 3500)
     {
         $timeStamp = time();
 
@@ -90,11 +90,12 @@ class OssService extends Service
         }
 
         $url = "";
+        $timestamp = $timeStamp + $expired;
         if(! file_exists($localFilePath)){
-            $url = $this->createUrl($objectKey);
+            $url = $this->createUrl($objectKey, $expired);
             $set = [
                 'url' => $url,
-                'timestamp' => $timeStamp + 3500,
+                'timestamp' => $timestamp,
             ];
             file_put_contents($localFilePath, json_encode($set));
         }else{