签名是正确的,但是给图片添加盲水印的时候,报400错误,报错信息如我上传的截图所示,请问是为什么?
报错信息如图所示
<?php
namespace App\Http\Controllers;
use App\Extensions\Tencent\Signature;
class IndexController extends Controller
{
protected $text = 'http://watermark-1256115051.picgz.myqcloud.com/tengxunyun.png';
protected $type = 2;
protected $host = 'watermark-1256115051.pic.ap-guangzhou.myqcloud.com';
protected $fileid = 'water.jpg';
protected $key = '123.jpg';
protected $authorization;
protected $guzzleHttpClient;
protected $filePath;
protected $fileSource;
public function __construct()
{
$this->guzzleHttpClient = new \GuzzleHttp\Client([
'base_uri' => 'http://pic.ap-guangzhou.myqcloud.com',
'timeout' => 30,
]);
$signature = new Signature(env('TENCENT_SECRETID'), env('TENCENT_SECRETKEY'));
$this->authorization = $signature->getAuthorization('PUT', $this->key);
$this->filePath = public_path('upload/images/20190511/abc.jpg');
$this->fileSource = fopen($this->filePath, 'rb');
}
public function index()
{
$picOperations = array(
'is_pic_info' => 1,
'rules' => [
[
'fileid' => $this->fileid,
'rule' => 'watermark/3/type/2/image/'.base64_encode($this->text)
]
]
);
$result = $this->guzzleHttpClient->request('PUT', '/'.$this->key, [
'headers'=>[
'Authorization' => $this->authorization,
'Host' => $this->host,
'Content-Length' => filesize($this->filePath),
'Pic-Operations' => json_encode($picOperations)
],
'body' => $this->fileSource
]);
dd($result->getBody()->getContents());
}
public function urlsafeB64encode($string) {
return base64_encode($string);
}
}
?>