See b2_list_buckets.
$buckets = $client->listBuckets();
See b2_create_bucket.
$bucketName = '...';
$bucket = $client->createBucket($bucketName);
Warning
By default,
createBucket()
will create a private bucket, which means authorization will be required to download files. Public buckets can also be created, however the files in these buckets can be downloaded by anyone (without authorization).
See b2_update_bucket.
$bucketId = '..';
$newBucketType = Bucket::TYPE_PUBLIC;
$bucket = $client->updateBucket($bucketId, $newBucketType);
See b2_delete_bucket.
$bucketId = '..';
$bucket = $client->deleteBucket($bucketId);
See CORS rules and lifecycle rules.
$bucketName = '...';
$bucketInfo = [
'key' => 'value',
];
$corsRules = [
[
'corsRuleName' => 'downloadFromAnyOrigin',
'allowedOrigins' => ['https'],
'allowedHeaders' => ['range'],
'allowedOperations' => [
'b2_download_file_by_id',
'b2_download_file_by_name',
],
'exposeHeaders' => ['x-bz-content-sha1'],
'maxAgeSeconds' => 3600
]
];
$lifecycleRules = [
'daysFromHidingToDeleting' => 1,
'daysFromUploadingToHiding' => 7,
'fileNamePrefix' => 'logs/'
];
$client->createBucket($bucketName, Bucket::TYPE_PRIVATE, $bucketInfo, $corsRules, $lifecycleRules);
// or
$client->updateBucket($bucketid, $bucketType, $bucketInfo, $corsRules, $lifecycleRules, $ifRevisionIs);