PHP code example of yareg / yii2-s3client
1. Go to this page and download the library: Download yareg/yii2-s3client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yareg / yii2-s3client example snippets
"yareg/yii2-s3client": "^2"
'components' => [
's3client' => [
'class'=> 'yareg\S3Client',
'key' => '<your key>',
'secret' => '<your secret>',
'endpoint'=> '<your endpoint>',
'region' => '<your region>',
'debug' => false, // optional
'http' => [ //optional
'verify' => false //use false to self-signed certs
],
],
],
shell
php composer.phar
/** @var S3Client $s3client */
$s3client = Yii::$app->s3client;
/**
* @param string $filePath
* @param string $bucket
* @param string $key
* @param array $meta
* @param array $tags
* @param array $args
* @return bool
*/
$s3client->putFile(string $filePath, string $bucket, string $key, array $meta = [], array $tags = [], array $args = []);
/**
* @param string $content
* @param string $bucket
* @param string $key
* @param array $meta
* @param array $tags
* @param array $args
* @return bool
*/
$s3client->putContent(string $content, string $bucket, string $key, array $meta = [], array $tags = [], array $args = []);
/**
* @param string $bucket
* @param string $key
* @param string|null $saveAs
* @return mixed|null
*/
$s3client->getObject(string $bucket, string $key, string $saveAs = null);
/**
* @param string $bucket
* @param string $prefix
*/
$s3client->listObjects(string $bucket, string $prefix = null);
/**
* @param string $bucket
* @param string $key
* @return bool
*/
$s3client->objectExists(string $bucket, string $key);
/**
* @param string $bucket
* @param array $keys
* @return bool
*/
$s3client->deleteObjects(string $bucket, array $keys = []);