初始化
更新时间 2025-09-28 10:58:21
最近更新时间: 2025-09-28 10:58:21
使用SDK功能前,需要新建s3Client,代码如下:
require '/path/to/autoload.php';
use Aws\S3\S3Client;
use Aws\Exception\AwsException;
use Aws\Credentials\Credentials;
const endpoint = '<your-endpoint>'; // e.g. http://endpoint or https://endpoint
const access_key = '<your-access-key>';
const secret_key = '<your-secret-key>';
$credentials = new Credentials(access_key, secret_key);
$s3Client = new S3Client([
'region' => 'ctyun', // region固定填ctyun
'version' => '2006-03-01', // s3接口版本号,固定填2006-03-01
'credentials' => $credentials,
'endpoint' => endpoint,
]);参数说明:
| 参数 | 说明 | 是否必要 |
|---|---|---|
| access_key | 用户账号 access key | 是 |
| secret_key | 用户账号 secret key | 是 |
| endpoint | 天翼云资源池的地址,必须指定http或https前缀 | 是 |