PHP code example of zhuangdebiao / swoole-cos-client

1. Go to this page and download the library: Download zhuangdebiao/swoole-cos-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zhuangdebiao / swoole-cos-client example snippets



\Swoole\Coroutine\run(function () {

    $config = new \ZhuangDeBiao\SwooleCosClient\Config([
        // 必填,app_id、secret_id、secret_key 
        // 可在个人秘钥管理页查看:https://console.cloud.tencent.com/capi
        'appId' => '1251196541',
        'secretId' => '',
        'secretKey' => '',
        // 地域列表请查看 https://cloud.tencent.com/document/product/436/6224
        'region' => 'ap-guangzhou',
        'bucket' => 'test-1251196541',
    ]);
    
    $object = new \ZhuangDeBiao\SwooleCosClient\ObjectClient($config);

    $filename = __DIR__ . '/1.png';
    $rt = $object->putObject('你好/1.png', $filename);
    var_dump($rt);

    $rt = $object->headObject('你好/1.png');
    var_dump($rt);

    var_dump($object->getUrl('你好/1.png'));

//    $rt = $object->deleteObject('你好/1.png');
//    var_dump($rt);
//
//    $rt = $object->headObject('你好/1.png');
//    var_dump($rt);

});