|
@@ -44,13 +44,13 @@ class TencentCosService extends BaseService |
|
@@ -44,13 +44,13 @@ class TencentCosService extends BaseService |
|
44
|
* @method :post
|
44
|
* @method :post
|
|
45
|
* @time :2023/7/19 14:47
|
45
|
* @time :2023/7/19 14:47
|
|
46
|
*/
|
46
|
*/
|
|
47
|
- public function uploadToCos($file,$path,$filename)
|
47
|
+ public function uploadToCos($path,$filename)
|
|
48
|
{
|
48
|
{
|
|
49
|
$objectKey = $path.'/'.$filename;
|
49
|
$objectKey = $path.'/'.$filename;
|
|
50
|
// 上传到腾讯云 COS
|
50
|
// 上传到腾讯云 COS
|
|
51
|
$httpClient = new Client();
|
51
|
$httpClient = new Client();
|
|
52
|
$response = $httpClient->request('PUT', "https://{$this->config['bucket']}.cos.{$this->config['cosRegion']}.myqcloud.com/{$objectKey}", [
|
52
|
$response = $httpClient->request('PUT', "https://{$this->config['bucket']}.cos.{$this->config['cosRegion']}.myqcloud.com/{$objectKey}", [
|
|
53
|
- 'body' => file_get_contents($file->getRealPath()),
|
53
|
+ 'body' => file_get_contents(config('filesystems.disks.upload')['root'].$objectKey),
|
|
54
|
'headers' => $this->generateHeaders($this->config['secretId'], $this->config['secretKey']),
|
54
|
'headers' => $this->generateHeaders($this->config['secretId'], $this->config['secretKey']),
|
|
55
|
]);
|
55
|
]);
|
|
56
|
// 若上传成功,则返回上传后的 URL
|
56
|
// 若上传成功,则返回上传后的 URL
|