初始化

使用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' => '',
	'version' => '2006-03-01',
	'credentials' => $credentials,
	'endpoint' => endpoint,
	// 设置超时
	//'http' => [
	//	'connect_timeout' => 10,
	//	'timeout' => 10,
	//]
]);
参数 说明
access_key 用户账号 access key
secret_key 用户账号 secret key
endpoint 天翼云资源池的地址,必须指定http或https前缀