freyo / flysystem-qcloud-cos-v5

💾 Flysystem Adapter for Tencent Cloud COS V5
https://intl.cloud.tencent.com/product/cos?lang=en
MIT License
156 stars 23 forks source link

Can I customize the request header #47

Closed 81867370 closed 2 years ago

81867370 commented 2 years ago

I want to use it with the qcloud-documents interface. I need to customize the request header. flysystem-qcloud-cos-v5 How do I add it

freyo commented 2 years ago
$disk = Storage::disk('cosv5');

// create a file
$disk->put('avatars/1', $fileContents, ['params' => [
    'ContentType' => 'image/png',
]]);

available parameters, see https://github.com/tencentyun/cos-php-sdk-v5/blob/master/src/Qcloud/Cos/Service.php#L1191

81867370 commented 2 years ago

I'm going to add the request header Pic-Operations: {"is_pic_info":1,"rules":[{"fileid":"test.jpg","rule":"imageView2/format/png"}]}

Am I going to write it like this `$disk = Storage::disk('cosv5');

// create a file $disk->put('avatars/1', $fileContents, ['params' => [ 'Pic-Operations' => ["is_pic_info"=>1,"rules"=>[["fileid"=>"test.jpg","rule"=>"imageView2/format/png"]]], ]]);`

freyo commented 2 years ago

try

$disk = Storage::disk('cosv5');

// create a file
$disk->put('avatars/1', $fileContents, ['params' => [
    'PicOperations' => '{"is_pic_info":1,"rules":[{"fileid":"test.jpg","rule":"imageView2/format/png"}]}',
]]);
81867370 commented 2 years ago

Thank you very much for your help, your code can be implemented.I also have a question, how to judge whether the file has been uploaded successfully? It seems that there is no information returned, so we can only judge by try catch

freyo commented 2 years ago

if fail, put only returns false