wzq před 5 roky
rodič
revize
3818172001

+ 12 - 2
app/Repositories/Post/PostRepository.php

@@ -82,8 +82,18 @@ class PostRepository
             ]);
         }
         if(isset($request['is_point']) && $request['is_point']){
-            $request['img'] = $this->uploadImage($request['img']);
-            Log::debug('内容上传图片结果'.json_encode($request['img']));
+            $res = $this->uploadImage($request['img']);
+            if($res && isset($res['data']) && isset($res['data']['url'])){
+                $request['img'] = config('customer.chxq_oss_url').$res['data']['url'];
+                Log::debug('内容上传图片成功结果'.json_encode($res));
+            }else{
+                Log::debug('内容上传图片失败结果'.json_encode($res));
+                return Response::create([
+                    'message' => '图片格式有误,请重试',
+                    'status_code' => 500
+                ]);
+            }
+
         }
         //验证话题
         $topicIdsArray = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();

+ 1 - 1
app/Traits/UserTrait.php

@@ -53,7 +53,7 @@ trait UserTrait
                 'multipart' => [
                     [
                         'name'     => 'image',
-                        'contents' => 'data',
+                        'contents' => fopen($fileUrl, 'r'),
                         'headers'  => ['X-Baz' => 'bar'],
                         'filename' => $fileUrl
                     ]

+ 1 - 0
config/customer.tpl

@@ -6,4 +6,5 @@ return [
     'VIRUS_URL' => '{VIRUS_URL}',
     'VIRUS_APP_ID' => '{VIRUS_APP_ID}',
     'VIRUS_APP_SECRET' => '{VIRUS_APP_SECRET}',
+    'chxq_oss_url' => '{chxq_oss_url}',
 ];