作者 李美松

v6优化程序 统计数据任务优化

  1 +<?php
  2 +
  3 +namespace App\Console\Commands\GeneratePDF;
  4 +
  5 +use App\Models\File\PdfFile;
  6 +use App\Models\ProjectAssociation\ProjectAssociation;
  7 +use App\Services\CosService;
  8 +use Barryvdh\DomPDF\Facade\Pdf;
  9 +use Illuminate\Console\Command;
  10 +
  11 +class GeneratePdfData extends Command
  12 +{
  13 +// use CmdSignal;
  14 +
  15 + /**
  16 + * The name and signature of the console command.
  17 + *
  18 + * @var string
  19 + */
  20 + protected $signature = 'generate_pdf_data';
  21 +
  22 + /**
  23 + * The console command description.
  24 + *
  25 + * @var string
  26 + */
  27 + protected $description = '生成v6绑定的aicc用户的pdf备用数据';
  28 +
  29 + // 最大支持5个进程
  30 + public $maxRunNumber = 50;
  31 +
  32 + /**
  33 + * Create a new command instance.
  34 + *
  35 + * @return void
  36 + */
  37 + public function __construct()
  38 + {
  39 + parent::__construct();
  40 + }
  41 +
  42 + public function handle()
  43 + {
  44 + return $this->main();
  45 + }
  46 +
  47 + /**
  48 + * @return int
  49 + */
  50 + public function start(): int
  51 + {
  52 + return $this->main();
  53 + }
  54 +
  55 + /**
  56 + * @return int
  57 + */
  58 + protected function main()
  59 + {
  60 + $month = date('m');
  61 + $list = ProjectAssociation::query()->whereStatus(ProjectAssociation::STATUS_NORMAL)
  62 + ->where('m_status', '!=', $month)->first();
  63 +
  64 + if (is_null($list)) {
  65 + $this->error('没有任务,等待中');
  66 + sleep(60);
  67 + return 0;
  68 + }
  69 + $pdfFile = new PdfFile();
  70 + $bool = $pdfFile->saveData(['pid' => $list->id]);
  71 + if (!$bool) {
  72 + $this->error('生成v6绑定的aicc用户的pdf备用数据添加失败');
  73 + return 0;
  74 + }
  75 + $list->m_status = $month;
  76 + $list->save();
  77 + $this->info('生成v6绑定的aicc用户的pdf备用数据添加成功');
  78 + return 0;
  79 + }
  80 +}
1 <?php 1 <?php
2 2
3 -namespace App\Console\Commands; 3 +namespace App\Console\Commands\GeneratePDF;
4 4
5 -use App\Http\Controllers\File\FileController;  
6 -use App\Models\File\DataFile; 5 +use App\Models\File\PdfFile;
7 use App\Models\ProjectAssociation\ProjectAssociation; 6 use App\Models\ProjectAssociation\ProjectAssociation;
8 use App\Services\CosService; 7 use App\Services\CosService;
9 use Barryvdh\DomPDF\Facade\Pdf; 8 use Barryvdh\DomPDF\Facade\Pdf;
@@ -12,7 +11,7 @@ use Illuminate\Http\File; @@ -12,7 +11,7 @@ use Illuminate\Http\File;
12 11
13 class ProjectFilePDF extends Command 12 class ProjectFilePDF extends Command
14 { 13 {
15 - use CmdSignal; 14 +// use CmdSignal;
16 15
17 /** 16 /**
18 * The name and signature of the console command. 17 * The name and signature of the console command.
@@ -28,14 +27,8 @@ class ProjectFilePDF extends Command @@ -28,14 +27,8 @@ class ProjectFilePDF extends Command
28 */ 27 */
29 protected $description = '网站项目数据,生成PDF文件'; 28 protected $description = '网站项目数据,生成PDF文件';
30 29
31 - protected $ProjectAssociation;  
32 -  
33 - protected $DataFile;  
34 -  
35 protected $time; 30 protected $time;
36 31
37 - protected $fileController;  
38 -  
39 protected $CosService; 32 protected $CosService;
40 33
41 // 最大支持5个进程 34 // 最大支持5个进程
@@ -48,71 +41,89 @@ class ProjectFilePDF extends Command @@ -48,71 +41,89 @@ class ProjectFilePDF extends Command
48 */ 41 */
49 public function __construct() 42 public function __construct()
50 { 43 {
51 - $this->ProjectAssociation = new ProjectAssociation();  
52 - $this->DataFile = new DataFile();  
53 - $this->time = date("Y-m");  
54 - $this->fileController = new FileController();  
55 - $this->CosService = new CosService(); 44 + $this->time = date("Y-m");
  45 + $this->CosService = new CosService();
56 parent::__construct(); 46 parent::__construct();
57 } 47 }
58 48
59 -// public function handle()  
60 -// {  
61 -// $project_data = [];  
62 -// $html = $this->html($project_data);  
63 -// $filename = hash('md5', $this->time . '-' . '$project_id' . '-' . '$friend_id' . '-' . '$user_id');  
64 -// $this->savePDF($html, $filename);  
65 -//// $this->testStreamPdf($html, $filename);  
66 -//// $file_path = $this->savePDF2($html, $filename);  
67 -// return 0;  
68 -// } 49 + public function handle()
  50 + {
  51 + // 开始时间
  52 + $startTime = microtime(true);
  53 + $html = $this->html([]);
  54 + $filename = hash('md5', $this->time . '-' . random_int(100000, 999999));
  55 + $this->savePDF($html, $filename);
  56 +
  57 + // 结束时间
  58 + $endTime = microtime(true);
  59 +
  60 + // 计算执行时间
  61 + $executionTime = ($endTime - $startTime);
  62 +
  63 + // 输出执行时间
  64 + var_dump("程序执行时间: " . $executionTime . " 秒");
  65 +// return $this->main();
  66 + }
69 67
  68 + /**
  69 + * @return int
  70 + */
70 public function start(): int 71 public function start(): int
71 { 72 {
72 - # 0 - 未生成  
73 - # 1 - 已生成  
74 - # 2 - 其它问题  
75 - $is_pdf = 0;  
76 - $lists = $this->ProjectAssociation::query()->where('is_pdf', $is_pdf)  
77 - ->where('project_id', '!=', 0)  
78 - ->where('friend_id', '!=', 0)  
79 - ->where('user_id', '!=', 0)  
80 - ->where('created_at', 'like', $this->time . '%')->first();  
81 -  
82 - if (is_null($lists)) {  
83 - $this->debug_echo('没有任务,等待中');  
84 - sleep(30); 73 + return $this->main();
  74 + }
  75 +
  76 + /**
  77 + * @return int
  78 + */
  79 + protected function main()
  80 + {
  81 + $list = PdfFile::query()->whereIsPdf(PdfFile::GENERATE_NOT_PDF)->first();
  82 +
  83 + if (is_null($list)) {
  84 + $this->error('没有任务,等待中');
  85 + sleep(60);
  86 + return 0;
  87 + }
  88 + $pid = $list->pid;
  89 + if (empty($pid)) {
  90 + $this->error('数据错误');
  91 + return 0;
  92 + }
  93 + $isExists = ProjectAssociation::query()->whereId($pid)->whereStatus(ProjectAssociation::STATUS_NORMAL)->first();
  94 + if (is_null($isExists)) {
  95 + $this->error('数据已被禁用 —— ' . $pid);
85 return 0; 96 return 0;
86 } 97 }
87 - $key = $this->signature . '-' . $lists->id;  
88 - $count = redis_get($key);  
89 98
90 - $project_id = $lists->project_id;  
91 - $user_id = $lists->user_id;  
92 - $friend_id = $lists->friend_id; 99 + $key = 'generate_pdf_' . $list->id;
  100 + $count = (int)redis_get($key) ?: 0;
  101 + $project_id = $isExists->project_id;
  102 + $user_id = $isExists->user_id;
  103 + $friend_id = $isExists->friend_id;
93 // todo 根据项目查询数据 104 // todo 根据项目查询数据
94 $project_data = []; 105 $project_data = [];
95 $html = $this->html($project_data); 106 $html = $this->html($project_data);
96 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id); 107 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
97 108
  109 + if ($count == 2) {
  110 + $list->is_pdf = PdfFile::GENERATE_OTHER_PDF;
  111 + $list->save();
  112 + $this->error('项目文件数据保存失败! - 其他原因 - ' . $key);
  113 + return 0;
  114 + }
  115 +
98 $file_path = $this->savePDF($html, $filename); 116 $file_path = $this->savePDF($html, $filename);
99 if (empty($file_path)) { 117 if (empty($file_path)) {
100 - $this->debug_echo('pdf生成失败!'); 118 + redis_set($key, $count + 1);
  119 + $this->error('pdf生成失败!');
101 return 0; 120 return 0;
102 } 121 }
103 - $isRes = $this->DataFile->saveData(compact('project_id', 'user_id', 'friend_id', 'file_path') + ['time' => $this->time]);  
104 - if (!$isRes) {  
105 - if ($count == 2) {  
106 - $lists->is_pdf = 2;  
107 - $lists->save();  
108 - $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key);  
109 - } else {  
110 - redis_set($key, $count + 1);  
111 - $this->debug_echo('项目文件数据保存失败! - ' . $key);  
112 - }  
113 - }  
114 - $lists->is_pdf = 1;  
115 - $lists->save(); 122 +
  123 + // 保存文件路径
  124 + $list->file_path = $file_path;
  125 + $list->is_pdf = PdfFile::GENERATE_PDF;
  126 + $list->save();
116 $this->info('项目文件数据保存成功!'); 127 $this->info('项目文件数据保存成功!');
117 return 0; 128 return 0;
118 } 129 }
@@ -131,18 +142,22 @@ class ProjectFilePDF extends Command @@ -131,18 +142,22 @@ class ProjectFilePDF extends Command
131 } 142 }
132 // 指定保存路径和文件名 143 // 指定保存路径和文件名
133 $savePath = $pdf_path . $filename . '.pdf'; 144 $savePath = $pdf_path . $filename . '.pdf';
  145 +
134 if (file_exists($savePath)) { 146 if (file_exists($savePath)) {
135 echo '文件已经存在'; 147 echo '文件已经存在';
136 return 0; 148 return 0;
137 } 149 }
138 150
139 - $pdf = PDF::loadHTML($html);  
140 - $pdf->save($savePath); 151 + $path = '/PDF/' . $this->time;
  152 + $pdf = PDF::loadHTML($html);
  153 +
  154 + // 获取二进制文件
  155 + $binary = $pdf->output(['compres' => 0]);
  156 + // 将文件保存到本地
  157 +// $pdf->save($savePath);
  158 +// $binary = new File($savePath);
141 159
142 - $path = '/V6/PDF/' . $this->time;  
143 - // 创建一个文件实例  
144 - $file = new File($savePath);  
145 - return $this->CosService->uploadFile($file, $path, $filename . '.pdf'); 160 + return $this->CosService->uploadFile($binary, $path, $filename . '.pdf');
146 } 161 }
147 162
148 /** 163 /**
@@ -153,6 +168,6 @@ class ProjectFilePDF extends Command @@ -153,6 +168,6 @@ class ProjectFilePDF extends Command
153 protected function html($item) 168 protected function html($item)
154 { 169 {
155 $font_path = storage_path('fonts\msyh.ttf'); 170 $font_path = storage_path('fonts\msyh.ttf');
156 - return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>'; 171 + return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试sdsd</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>';
157 } 172 }
158 } 173 }
1 <?php 1 <?php
2 2
3 -namespace App\Console\Commands; 3 +namespace App\Console\Commands\GeneratePDF;
4 4
5 -use App\Models\File\DataFile; 5 +use App\Models\File\PdfFile;
  6 +use App\Models\ProjectAssociation\ProjectAssociation;
6 use Illuminate\Console\Command; 7 use Illuminate\Console\Command;
7 8
8 -class WebsiteData extends Command 9 +class PushAiccData extends Command
9 { 10 {
10 - use CmdSignal; 11 +// use CmdSignal;
11 12
12 /** 13 /**
13 * The name and signature of the console command. 14 * The name and signature of the console command.
14 * 15 *
15 * @var string 16 * @var string
16 */ 17 */
17 - protected $signature = 'website_data'; 18 + protected $signature = 'push_data_to_aicc';
18 19
19 /** 20 /**
20 * The console command description. 21 * The console command description.
@@ -39,41 +40,65 @@ class WebsiteData extends Command @@ -39,41 +40,65 @@ class WebsiteData extends Command
39 parent::__construct(); 40 parent::__construct();
40 } 41 }
41 42
  43 +
  44 + public function handle()
  45 + {
  46 + return $this->main();
  47 + }
  48 +
42 public function start(): int 49 public function start(): int
43 { 50 {
44 - # 0 - 未推送  
45 - # 1 - 已推送  
46 - # 2 - 其他问题  
47 - $status = 0;  
48 - $lists = DataFile::query()->where('status', $status)  
49 - ->where('created_at', 'like', $this->time . '%')->first();  
50 - if (is_null($lists)) {  
51 - $this->debug_echo('没有任务,等待中');  
52 - sleep(30); 51 + return $this->main();
  52 + }
  53 +
  54 + protected function main()
  55 + {
  56 + $list = PdfFile::query()->whereIsPdf(PdfFile::GENERATE_PUSH)->whereIsPush(PdfFile::GENERATE_NOT_PUSH)->first();
  57 + if (is_null($list)) {
  58 + $this->error('向AICC推送 - 没有任务,等待中');
  59 + sleep(60);
  60 + return 0;
  61 + }
  62 +
  63 + $pid = $list->pid;
  64 + if (empty($pid)) {
  65 + $this->error('向AICC推送数据错误');
  66 + return 0;
  67 + }
  68 + $isExists = ProjectAssociation::query()->whereId($pid)->whereStatus(ProjectAssociation::STATUS_NORMAL)->first();
  69 + if (is_null($isExists)) {
  70 + $this->error('向AICC推送数据已被禁用 —— ' . $pid);
53 return 0; 71 return 0;
54 } 72 }
55 73
56 - $key = $this->signature . '-' . $lists->id;  
57 - $count = redis_get($key);  
58 - $data = $lists; 74 + $key = 'push_data_to_aicc_' . $list->id;
  75 + $count = (int)redis_get($key) ?: 0;
  76 +
  77 + $data = $list->toArray();
  78 + $data['project_id'] = $isExists->project_id;
  79 + $data['friend_id'] = $isExists->friend_id;
  80 + $data['user_id'] = $isExists->user_id;
  81 +
59 $url = env('AICC_URL'); 82 $url = env('AICC_URL');
60 $msg = http_post($url, json_encode(compact('data'))); 83 $msg = http_post($url, json_encode(compact('data')));
61 $status_code = 0; 84 $status_code = 0;
62 if ($msg) { 85 if ($msg) {
63 $status_code = (int)$msg['status']; 86 $status_code = (int)$msg['status'];
64 } 87 }
  88 + if ($count == 2) {
  89 + $list->is_push = PdfFile::GENERATE_OTHER_PUSH;
  90 + $list->save();
  91 + $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key);
  92 + return 0;
  93 + }
  94 +
65 if ($status_code != 200) { 95 if ($status_code != 200) {
66 - if ($count == 2) {  
67 - $lists->status = 2;  
68 - $lists->save();  
69 - $this->debug_echo('项目文件数据保存失败! - 其他原因 - ' . $key);  
70 - } else {  
71 - redis_set($key, $count + 1);  
72 - $this->debug_echo('项目文件数据保存失败! - ' . $key);  
73 - } 96 + redis_set($key, $count + 1);
  97 + $this->debug_echo('项目文件数据保存失败! - ' . $key);
  98 + return 0;
74 } 99 }
75 - $lists->status = 1;  
76 - $lists->save(); 100 + $list->is_push = PdfFile::GENERATE_PUSH;
  101 + $list->save();
77 $this->info('项目文件数据保存成功!'); 102 $this->info('项目文件数据保存成功!');
78 return 0; 103 return 0;
79 } 104 }
1 -<?php  
2 -  
3 -namespace App\Models\File;  
4 -  
5 -use App\Models\Base;  
6 -  
7 -class DataFile extends Base  
8 -{  
9 - protected $table = 'gl_data_file';  
10 -  
11 - public function saveData(array $data): bool  
12 - {  
13 - # v6项目ID  
14 - $project_id = (int)$data['project_id'] ?? 0;  
15 - $isRes = self::query()->where('project_id', $project_id)->where('created_at', 'like', $data['time'] . '%')->first();  
16 - if (!$isRes) {  
17 - $isRes = new self();  
18 - $isRes->project_id = $project_id;  
19 - # AICC用户ID  
20 - $isRes->user_id = $data['user_id'];  
21 - # 第三方朋友ID  
22 - $isRes->friend_id = $data['friend_id'];  
23 - # 生成文件路径  
24 - $isRes->file_path = $data['file_path'];  
25 - }  
26 - return $isRes->save();  
27 - }  
28 -  
29 - /**  
30 - * @param int $page  
31 - * @param int $perPage  
32 - * @return array  
33 - */  
34 - public function allData(int $page = 1, int $perPage = 15)  
35 - {  
36 - $lists = self::query()->paginate($perPage, ['*'], 'page', $page);  
37 - $items = $lists->Items();  
38 - $totalPage = $lists->lastPage();  
39 - $total = $lists->total();  
40 - $currentPage = $lists->currentPage();  
41 - return compact('total', 'items', 'totalPage', 'currentPage');  
42 - }  
43 -  
44 -}  
  1 +<?php
  2 +
  3 +namespace App\Models\File;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +/**
  8 + * App\Models\File\PdfFile
  9 + *
  10 + * @property int $id
  11 + * @property int $pid AICC用户ID
  12 + * @property string $file_path 生成文件路径
  13 + * @property int $is_pdf 0 - 未生成 1 - 已生成 2 - 其它问题
  14 + * @property int|null $is_push 0 - 未推送 1 - 已推送 2 - 其他问题
  15 + * @property \Illuminate\Support\Carbon|null $created_at
  16 + * @property \Illuminate\Support\Carbon|null $updated_at
  17 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile newModelQuery()
  18 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile newQuery()
  19 + * @method static \Illuminate\Database\Eloquent\Builder|PdfFile query()
  20 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereCreatedAt($value)
  21 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereFilePath($value)
  22 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereId($value)
  23 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereIsPdf($value)
  24 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereIsPush($value)
  25 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile wherePid($value)
  26 + * @method \Illuminate\Database\Eloquent\Builder|PdfFile whereUpdatedAt($value)
  27 + * @mixin \Eloquent
  28 + */
  29 +class PdfFile extends Base
  30 +{
  31 + protected $table = 'gl_pdf_file';
  32 +
  33 + /** @var int PDF - 未生成 */
  34 + const GENERATE_NOT_PDF = 0;
  35 +
  36 + /** @var int PDF - 已生成 */
  37 + const GENERATE_PDF = 1;
  38 +
  39 + /** @var int PDF - 其它问题 */
  40 + const GENERATE_OTHER_PDF = 2;
  41 +
  42 + /** @var int AICC - 未推送 */
  43 + const GENERATE_NOT_PUSH = 0;
  44 + /** @var int AICC - 已推送 */
  45 + const GENERATE_PUSH = 1;
  46 + /** @var int AICC - 其他问题 */
  47 + const GENERATE_OTHER_PUSH = 2;
  48 +
  49 + public function saveData(array $data): bool
  50 + {
  51 + # v6项目ID
  52 + $pid = (int)$data['pid'] ?? 0;
  53 + $time = $data['time'] ?? date('Y-m-d');
  54 + $isRes = self::query()->wherePid($pid)->where('created_at', 'like', $time . '%')->first();
  55 + if (!$isRes) {
  56 + $isRes = new self();
  57 + $isRes->pid = $pid;
  58 + # 生成文件路径
  59 + $isRes->file_path = $data['file_path'] ?? '';
  60 + }
  61 + return $isRes->save();
  62 + }
  63 +
  64 +}
@@ -5,10 +5,47 @@ namespace App\Models\ProjectAssociation; @@ -5,10 +5,47 @@ namespace App\Models\ProjectAssociation;
5 use Illuminate\Database\Eloquent\Builder; 5 use Illuminate\Database\Eloquent\Builder;
6 use Illuminate\Database\Eloquent\Model; 6 use Illuminate\Database\Eloquent\Model;
7 7
  8 +/**
  9 + * App\Models\ProjectAssociation\ProjectAssociation
  10 + *
  11 + * @property int $id
  12 + * @property int $project_id V6项目ID
  13 + * @property int $friend_id AICC朋友ID
  14 + * @property int $user_id AICC用户ID
  15 + * @property string|null $nickname AICC朋友昵称
  16 + * @property string|null $user_name AICC用户姓名
  17 + * @property string|null $image AICC朋友头像
  18 + * @property int|null $status 1 - 正常, 0 - 禁用
  19 + * @property int|null $m_status 统计当月是否生成数据
  20 + * @property \Illuminate\Support\Carbon|null $created_at
  21 + * @property \Illuminate\Support\Carbon|null $updated_at
  22 + * @method Builder|ProjectAssociation newModelQuery()
  23 + * @method Builder|ProjectAssociation newQuery()
  24 + * @method static Builder|ProjectAssociation query()
  25 + * @method Builder|ProjectAssociation whereCreatedAt($value)
  26 + * @method Builder|ProjectAssociation whereFriendId($value)
  27 + * @method Builder|ProjectAssociation whereId($value)
  28 + * @method Builder|ProjectAssociation whereImage($value)
  29 + * @method Builder|ProjectAssociation whereMStatus($value)
  30 + * @method Builder|ProjectAssociation whereNickname($value)
  31 + * @method Builder|ProjectAssociation whereProjectId($value)
  32 + * @method Builder|ProjectAssociation whereStatus($value)
  33 + * @method Builder|ProjectAssociation whereUpdatedAt($value)
  34 + * @method Builder|ProjectAssociation whereUserId($value)
  35 + * @method Builder|ProjectAssociation whereUserName($value)
  36 + * @mixin \Eloquent
  37 + */
8 class ProjectAssociation extends Model 38 class ProjectAssociation extends Model
9 { 39 {
  40 +
10 protected $table = 'gl_project_association'; 41 protected $table = 'gl_project_association';
11 42
  43 + /** @var int 数据状态 - 正常 */
  44 + const STATUS_NORMAL = 1;
  45 +
  46 + /** @var int 数据状态 - 禁用 */
  47 + const STATUS_DISABLED = 0;
  48 +
12 /** 49 /**
13 * 保存|修改数据 50 * 保存|修改数据
14 * @param array $data 51 * @param array $data
@@ -35,7 +35,8 @@ class CosService @@ -35,7 +35,8 @@ class CosService
35 $cosClient->putObject([ 35 $cosClient->putObject([
36 'Bucket' => $cos['bucket'], 36 'Bucket' => $cos['bucket'],
37 'Key' => $key, 37 'Key' => $key,
38 - 'Body' => fopen($files->getRealPath(), 'r'), 38 +// 'Body' => fopen($files->getRealPath(), 'r'),
  39 + 'Body' => $files,
39 ]); 40 ]);
40 return $key; 41 return $key;
41 } 42 }
@@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
23 "swooletw/laravel-swoole": "^2.13" 23 "swooletw/laravel-swoole": "^2.13"
24 }, 24 },
25 "require-dev": { 25 "require-dev": {
  26 + "barryvdh/laravel-ide-helper": "^2.13",
26 "facade/ignition": "^2.5", 27 "facade/ignition": "^2.5",
27 "fakerphp/faker": "^1.9.1", 28 "fakerphp/faker": "^1.9.1",
28 "laravel/sail": "^1.0.1", 29 "laravel/sail": "^1.0.1",