Skip to content

AzureBlobContainerClient

AzureBlobClient bound to one container, so it satisfies ListableObjectStoreClientInterface like the S3 and GCS clients do.

Azure takes the container per call, where S3 and GCS bind the bucket to the client itself. That is the only shape difference between the three, and binding it here is what lets a consumer be written once against the interface instead of once per provider.

The container is created on first write, as AzureBlobClient::ensureContainerExists() allows — a read against a container that does not exist answers null, which is the same thing a read of an absent blob answers.

final class AzureBlobContainerClient implements ListableObjectStoreClientInterface

ImplementsListableObjectStoreClientInterface
Since3.2.0
SourceAzureBlobContainerClient.php

public function __construct(AzureBlobClient $client, string $container): mixed

ParameterTypeDescription
$clientAzureBlobClient
$containerstring

Returns mixed

MethodDescription
blobClient(): AzureBlobClientThe underlying client, for the Azure-specific operations this contract does not cover.
container(): stringReturns the name of the container every key on this client resolves against.
delete(string $key): voidDeletes from the bound container; the container itself is never created for a delete.
get(string $key): ?stringReads from the bound container.
head(string $key): ?ObjectMetadataIssues an Azure Get Blob Properties request against the bound container, so no body is transferred.
listObjects(string $prefix = '', string $delimiter = '', ?string $continuationToken = null, int $maxKeys = 1000): ObjectListingLists blobs in the bound container.
put(string $key, string $body): voidThe bound container is created on the first write of this instance’s lifetime and the result remembered, so later writes cost one request rather than two.

public function blobClient(): AzureBlobClient

The underlying client, for the Azure-specific operations this contract does not cover.

Returns AzureBlobClient

public function container(): string

Returns the name of the container every key on this client resolves against.

Returns string

public function delete(string $key): void

Deletes from the bound container; the container itself is never created for a delete.

Best-effort: a key that does not exist is not an error.

ParameterTypeDescription
$keystring
ThrowsWhen
ObjectStoreExceptionOn a transport or provider failure.

public function get(string $key): ?string

Reads from the bound container.

A container that has not been created yet reads as null, the same answer a missing blob gives.

ParameterTypeDescription
$keystring

Returns ?``string

ThrowsWhen
ObjectStoreExceptionOn a transport or provider failure, as distinct from a missing object.

public function head(string $key): ?ObjectMetadata

Issues an Azure Get Blob Properties request against the bound container, so no body is transferred.

ParameterTypeDescription
$keystring

Returns ?ObjectMetadata

ThrowsWhen
ObjectStoreExceptionOn a transport or provider failure.

public function listObjects(string $prefix = '', string $delimiter = '', ?string $continuationToken = null, int $maxKeys = 1000): ObjectListing

Lists blobs in the bound container.

With $delimiter empty, every matching key comes back as an ObjectSummary in ObjectListing::$objects — a fully recursive listing. With $delimiter set, a key is only listed that way when $prefix (plus nothing else) reaches it before the first occurrence of $delimiter; everything past that point is collapsed into one entry per distinct prefix-up-to-and-including-the-delimiter in ObjectListing::$commonPrefixes instead — the “one directory level” view every provider’s own console uses.

$continuationToken must be null on the first call and, for a truncated result, ObjectListing::$nextContinuationToken verbatim on the next — it is opaque, provider specific, and never meant to be inspected or constructed by a caller.

ParameterTypeDescription
$prefixstring
$delimiterstring
$continuationToken?``string
$maxKeysint

Returns ObjectListing

ThrowsWhen
ObjectStoreExceptionOn a transport or provider failure.

public function put(string $key, string $body): void

The bound container is created on the first write of this instance’s lifetime and the result remembered, so later writes cost one request rather than two.

ParameterTypeDescription
$keystring
$bodystring
ThrowsWhen
ObjectStoreExceptionIf the write does not succeed.