Skip to content

BucketModel

Craig edited this page Jan 1, 2024 · 4 revisions

Get the bucket's unique ID

$bucketId = $bucket->getId();
// e.g: abc123def456ghi789jkl

Get the bucket's friendly name

$bucketName = $bucket->getName();
// e.g This-Bucket-Is-So-Cool

Get the bucket's type

$type = $bucket->getType();
// e.g allPublic

Get the bucket's revision number

$revision = $bucket->getRevision();
// e.g 2

Get the bucket's CORS rules as an array.

$corsRules = $bucket->getCORSRules();
// e.g [0] => [
//    'allowedHeaders' => [
//      'authorization',
//      'range'
//    ],
//    'allowedOperations' => [
//      'b2_download_file_by_id',
//      'b2_download_file_by_name',
//    ],
//    'allowedOrigins' => ['https'],
//    'corsRuleName' => 'downloadFromAnyHttpsOrigin',
//    'exposeHeaders' => null,
//    'maxAgeSeconds' => 3600,
//  ],
//  ...

Get the bucket's SSE configuration

$sse = $bucket->getServerSideEncryption();
// e.g [
//    'algorithm' => 'AES256',
//    'mode' => 'SSE-B2',
//  ],
//  ...

Get the bucket's file-lock configuration

$fileLock = $bucket->getFileLock();
// e.g [0] => [
//    'defaultRetention' => [
//      'mode' => 'value',
//      'period' => 'value',
//    ],
//    'isFileLockEnabled' => true,
//  ],
//  ...

Get the bucket's lifecycle rules as an array

$lifecycleRules = $bucket->getLifeCycleRules();
// e.g [
//    'daysFromHidingToDeleting' => 7
//    'daysFromUploadingToHiding' => null,
//    'fileNamePrefix' => null,
//  ],
//  ...

Get the bucket's replication configuration

$replication = $bucket->getReplicationConfig();
// e.g [asReplicationSource] => [
//    'replicationRules' => [
//      [0] => [
//        'destinationBucketId' => 'DESTINATION_BUCKET_ID',
//        'fileNamePrefix' => 'value',
//        'includeExistingFiles' => true,
//        'isEnabled' => true,
//        'priority' => 1,
//        'replicationRuleName' => 'demo-replication',
//      ],
//    ],
//    'sourceApplicationKeyId' => 'KEY_ID',
//  ],
//  ...