test
This commit is contained in:
30
scratch/create_bucket.php
Normal file
30
scratch/create_bucket.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Aws\S3\S3Client;
|
||||
use Aws\Exception\AwsException;
|
||||
|
||||
$s3Client = new S3Client([
|
||||
'version' => 'latest',
|
||||
'region' => 'us-east-1',
|
||||
'endpoint' => 'http://minio:9000',
|
||||
'use_path_style_endpoint' => true,
|
||||
'credentials' => [
|
||||
'key' => 'admin',
|
||||
'secret' => 'password',
|
||||
],
|
||||
]);
|
||||
|
||||
try {
|
||||
$result = $s3Client->createBucket([
|
||||
'Bucket' => 'quyoshli',
|
||||
]);
|
||||
echo "Bucket 'quyoshli' created successfully.\n";
|
||||
} catch (AwsException $e) {
|
||||
if ($e->getAwsErrorCode() == 'BucketAlreadyOwnedByYou' || $e->getAwsErrorCode() == 'BucketAlreadyExists') {
|
||||
echo "Bucket 'quyoshli' already exists.\n";
|
||||
} else {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user