初始化
更新時間 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. //endpoint or //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前綴 | 是 |