本文介绍删除桶的示例代码。
您可以通过 TosClient->deleteBucket 删除桶,示例代码如下:
<?php // 假设使用 composer 安装 require_once __DIR__ . '/vendor/autoload.php'; use Tos\TosClient; use Tos\Exception\TosClientException; use Tos\Exception\TosServerException; use Tos\Model\DeleteBucketInput; try { $client = new TosClient([ 'region' => 'your region', 'endpoint' => 'your endpoint', // 从环境变量中获取访问密钥 'ak' => getenv('TOS_ACCESS_KEY'), 'sk' => getenv('TOS_SECRET_KEY'), ]); $input = new DeleteBucketInput('bucket-test'); $output = $client->deleteBucket($input); echo $output->getRequestId() . PHP_EOL; } catch (TosClientException $ex) { echo $ex->getMessage() . PHP_EOL; } catch (TosServerException $ex) { echo $ex->getRequestId() . PHP_EOL; echo $ex->getStatusCode() . PHP_EOL; echo $ex->getErrorCode() . PHP_EOL; }