try{$result = $cosClient->putObject(array('Bucket' => 'examplebucket-125000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket'Key' => 'exampleobject''Body' => 'string','ServerSideEncryption' => 'AES256',// SSE-COS encryption),);print_r ($result);} catch (Qcloud\\Cos\\Exception\\ServiceResponseException $e) {echo $e;}
<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual `region`, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', // Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));$bucket = 'examplebucket-125000000'; // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket$key = 'exampleobject';try{$customerKey = 'abcdefghijklmnopqrstuvwxyz123456'; // A 32-byte character string that can contain numbers, letters, and special characters, but not Chinese characters$SSECustomerKey = base64_encode($customerKey);$SSECustomerKeyMd5 = base64_encode(md5($customerKey, true));$result = $cosClient->putObject(array('Bucket' => $bucket,'Key' => $key,'Body' => 'string','SSECustomerAlgorithm' => 'AES256','SSECustomerKey' => $SSECustomerKey,'SSECustomerKeyMD5' => $SSECustomerKeyMd5,));print_r ($result);} catch (Qcloud\\Cos\\Exception\\ServiceResponseException $e) {echo $e;}
Was this page helpful?