ソースを参照

Merge branch 'v5.1.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.1.0dev

evoxwht 2 年 前
コミット
0fd959d9b5

+ 15 - 2
crmeb/app/adminapi/controller/v1/product/StoreProduct.php

@@ -19,6 +19,7 @@ use app\services\product\product\StoreProductServices;
 use crmeb\services\FileService;
 use app\services\other\UploadService;
 use think\facade\App;
+use think\Request;
 
 /**
  * Class StoreProduct
@@ -339,10 +340,22 @@ class StoreProduct extends AuthController
      * @return mixed
      * @throws \Exception
      */
-    public function getTempKeys()
+    public function getTempKeys(Request $request)
     {
         $upload = UploadService::init();
-        $re = $upload->getTempKeys();
+        $type = (int)sys_config('upload_type', 1);
+        $key = $request->get('key', '');
+        $path = $request->get('path', '');
+        $contentType = $request->get('contentType', '');
+        if ($type === 5) {
+            if (!$key || !$contentType) {
+                return app('json')->fail('缺少参数');
+            }
+            $url = $upload->getTempKeys($key, $path, $contentType);
+            $re = ['url' => $url];
+        } else {
+            $re = $upload->getTempKeys();
+        }
         return $re ? app('json')->success($re) : app('json')->fail(100016);
     }
 

+ 5 - 4
crmeb/crmeb/services/upload/storage/Jdoss.php

@@ -345,17 +345,18 @@ class Jdoss extends BaseUpload
      * 获取OSS上传密钥
      * @return mixed|void
      */
-    public function getTempKeys($key = '', $path = '', $expires = '+10 minutes')
+    public function getTempKeys($key = '', $path = '', $contentType = '', $expires = '+10 minutes')
     {
         try {
             $app = $this->app();
-            $cmd = $app->getCommand([
+            $cmd = $app->getCommand(
                 'PutObject', [
                     'Bucket' => $this->storageName,
                     'Key' => $key,
-                    'SourceFile' => $path
+                    'SourceFile' => $path,
+                    'ContentType' => $contentType
                 ]
-            ]);
+            );
             $request = $app->createPresignedRequest($cmd, $expires);
             return (string)$request->getUri();
         } catch (\Throwable $e) {