|
...
|
...
|
@@ -43,7 +43,7 @@ class TencentCosService extends BaseService |
|
|
|
public function upload_image($path,$fileName){
|
|
|
|
// 构建请求URL
|
|
|
|
$pathname = '/'.$this->config['bucket'].$path.'/'.$fileName;
|
|
|
|
$signature = $this->generateSignature();
|
|
|
|
$signature = $this->generateSignature($path.'/'.$fileName);
|
|
|
|
$url = 'https://'.$this->config['bucket'].'.cos.'.$this->config['cosRegion'].'.myqcloud.com'.$pathname.'?sign='.$signature;
|
|
|
|
// 打开文件流
|
|
|
|
$url_path = config('filesystems.disks.upload')['root'].$path.'/'.$fileName;
|
|
...
|
...
|
@@ -83,11 +83,11 @@ class TencentCosService extends BaseService |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/18 17:10
|
|
|
|
*/
|
|
|
|
public function generateSignature() {
|
|
|
|
public function generateSignature($path) {
|
|
|
|
$signTime = time();
|
|
|
|
$expiredTime = time() + 3600;
|
|
|
|
$plainText = 'a='.$this->config['appId'].'&b='.$this->config['bucket'].
|
|
|
|
'&k='.$this->config['secretId'].'&e='.$expiredTime.'&t='.$signTime.'&r='.rand().'&f=';;
|
|
|
|
$plainText =
|
|
|
|
'a='.$this->config['appId'].'&b='.$this->config['bucket']. '&k='.$this->config['secretId'].'&e='.$expiredTime.'&t='.$signTime.'&r='.rand().'&f='.$path;
|
|
|
|
$sign = base64_encode(hash_hmac('SHA1', $plainText, $this->config['secretKey'], true).$plainText);
|
|
|
|
return $sign;
|
|
|
|
}
|
...
|
...
|
|