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