正在显示
1 个修改的文件
包含
1 行增加
和
3 行删除
| @@ -43,6 +43,7 @@ class TencentCosService extends BaseService | @@ -43,6 +43,7 @@ class TencentCosService extends BaseService | ||
| 43 | * @time :2023/7/18 16:56 | 43 | * @time :2023/7/18 16:56 |
| 44 | */ | 44 | */ |
| 45 | public function upload_image($path,$fileName,$image_type){ | 45 | public function upload_image($path,$fileName,$image_type){ |
| 46 | + $contentType = 'image/'.$image_type; | ||
| 46 | $httpVerb = 'PUT'; | 47 | $httpVerb = 'PUT'; |
| 47 | $date = gmdate('D, d M Y H:i:s \G\M\T'); | 48 | $date = gmdate('D, d M Y H:i:s \G\M\T'); |
| 48 | //生成 KeyTime | 49 | //生成 KeyTime |
| @@ -50,12 +51,9 @@ class TencentCosService extends BaseService | @@ -50,12 +51,9 @@ class TencentCosService extends BaseService | ||
| 50 | //生成 SignKey | 51 | //生成 SignKey |
| 51 | $signKey = hash_hmac( 'sha1', $signTime, trim($this->config['secretKey']) ); | 52 | $signKey = hash_hmac( 'sha1', $signTime, trim($this->config['secretKey']) ); |
| 52 | //生成 UrlParamList 和 HttpParameters | 53 | //生成 UrlParamList 和 HttpParameters |
| 53 | - | ||
| 54 | $filePath = $path.'/'.$fileName; | 54 | $filePath = $path.'/'.$fileName; |
| 55 | $stringToSign = "{$httpVerb}\n\n\n{$date}\n/{$this->config['bucket']}/{$filePath}"; | 55 | $stringToSign = "{$httpVerb}\n\n\n{$date}\n/{$this->config['bucket']}/{$filePath}"; |
| 56 | $sign = hash_hmac( 'sha1', $stringToSign, $signKey ); | 56 | $sign = hash_hmac( 'sha1', $stringToSign, $signKey ); |
| 57 | - var_dump($sign); | ||
| 58 | - die(); | ||
| 59 | $authorization = | 57 | $authorization = |
| 60 | "q-sign-algorithm=sha1&q-ak={$this->config['secretId']}&q-sign-time={$signTime}&q-key-time={$signTime}&q-header-list=&q-url-param-list=&q-signature={$sign}"; | 58 | "q-sign-algorithm=sha1&q-ak={$this->config['secretId']}&q-sign-time={$signTime}&q-key-time={$signTime}&q-header-list=&q-url-param-list=&q-signature={$sign}"; |
| 61 | $url = "https://{$this->config['bucket']}.cos.{$this->config['cosRegion']}.myqcloud.com{$filePath}"; | 59 | $url = "https://{$this->config['bucket']}.cos.{$this->config['cosRegion']}.myqcloud.com{$filePath}"; |
-
请 注册 或 登录 后发表评论