kenreilly/yii2-s3

作为 Yii2 组件的 Amazon S3Client 包装器

1.2 2018-01-20 01:49 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:36:54 UTC


README

作为 Yii2 组件的 Amazon S3Client 包装器。

使用方法

return [
	// ...
	'components' => [
		'storage' => [
			'class' => '\jovanialferez\yii2s3\AmazonS3',
			'key' => 'AWS_ACCESS_KEY_ID',
			'secret' => 'AWS_SECRET_ACCESS_KEY',
			'bucket' => 'YOUR_BUCKET',
		],
		// ...
	],
];

然后您可以使用此组件,如下所示:

$storage = \Yii::$app->storage;

// uploadFile() here returns the resulting S3 url of that file
$url = $storage->uploadFile('/path/to/file', 'unique_file_name');