|
@@ -21,7 +21,7 @@ class CosService |
|
@@ -21,7 +21,7 @@ class CosService |
|
21
|
* @method :post
|
21
|
* @method :post
|
|
22
|
* @time :2023/7/19 15:28
|
22
|
* @time :2023/7/19 15:28
|
|
23
|
*/
|
23
|
*/
|
|
24
|
- public function uploadFile(&$files,$path,$filename)
|
24
|
+ public function uploadFile(&$files,$path,$filename, $binary = false)
|
|
25
|
{
|
25
|
{
|
|
26
|
$cos = config('filesystems.disks.cos');
|
26
|
$cos = config('filesystems.disks.cos');
|
|
27
|
$cosClient = new Client([
|
27
|
$cosClient = new Client([
|
|
@@ -32,11 +32,11 @@ class CosService |
|
@@ -32,11 +32,11 @@ class CosService |
|
32
|
],
|
32
|
],
|
|
33
|
]);
|
33
|
]);
|
|
34
|
$key = $path.'/'.$filename;
|
34
|
$key = $path.'/'.$filename;
|
|
|
|
35
|
+ $Body = $binary ? $files : fopen($files->getRealPath(), 'r');
|
|
35
|
$cosClient->putObject([
|
36
|
$cosClient->putObject([
|
|
36
|
'Bucket' => $cos['bucket'],
|
37
|
'Bucket' => $cos['bucket'],
|
|
37
|
'Key' => $key,
|
38
|
'Key' => $key,
|
|
38
|
-// 'Body' => fopen($files->getRealPath(), 'r'),
|
|
|
|
39
|
- 'Body' => $files,
|
39
|
+ 'Body' => $Body,
|
|
40
|
]);
|
40
|
]);
|
|
41
|
return $key;
|
41
|
return $key;
|
|
42
|
}
|
42
|
}
|