Tiger_Media_Storage_Azure

@api Β· implements Tiger_Media_Storage_Interface

Tiger_Media_Storage_Azure β€” Azure Blob Storage media storage.

Same contract as the S3/GCS adapters, adapted to Azure's model where public access is a container-level setting (not per-object/prefix). Two layouts:

  • Two containers (set BOTH public_container + private_container): visibility picks the container; make the public one's access level "blob". Blob name = <prefix><key>.
  • One container (container): visibility picks a key prefix (public_prefix/ private_prefix) within it, like S3/GCS. "Public" is only truly public if that container's access level allows it β€” else front it with a CDN.

PUBLIC β†’ a direct CDN / *.blob.core.windows.net URL. PRIVATE β†’ a short-lived SAS URL (presign_ttl, needs the account key), or '' when the key is absent / presign_ttl=0 (the media layer then streams through the ACL-checked /media/file/ route).

Auth: a connection_string, or account + key. Requires microsoft/azure-storage-blob (optional dependency β€” composer suggest / MEDIA.md); the adapter throws a clear message if it's missing and only loads when an azure disk is used.

Methods

__construct()

__construct(array $config)

Configure containers, prefixes, CDN, and presign TTL from the disk config.

  • $config array β€” the media.disks.<name>.* settings

Throws RuntimeException β€” when neither a single container nor both public/private containers are set

put()

put($key, $sourcePath, $visibility, $mime = null)

Store bytes from a source file path as a block blob.

  • $key string β€” the adapter-relative storage key
  • $sourcePath string β€” the source file on disk to read from
  • $visibility string β€” public|private
  • $mime ?string β€” the content MIME type (may be null)

Throws RuntimeException β€” when the source can't be read or the blob can't be created

write()

write($key, $bytes, $visibility, $mime = null)

Store raw bytes as a block blob.

  • $key string β€” the adapter-relative storage key
  • $bytes string β€” the raw bytes to store
  • $visibility string β€” public|private
  • $mime ?string β€” the content MIME type (may be null)

get()

get($key, $visibility)

Read all bytes of a blob.

  • $key string β€” the adapter-relative storage key
  • $visibility string β€” public|private

Returns string β€” the blob's bytes

Throws RuntimeException β€” when the blob is not found

stream()

stream($key, $visibility)

Open a read stream for a blob.

  • $key string β€” the adapter-relative storage key
  • $visibility string β€” public|private

Returns resource β€” a readable stream for the blob

Throws RuntimeException β€” when the blob is not found

delete()

delete($key, $visibility)

Remove a blob (idempotent β€” a missing blob is not an error).

  • $key string β€” the adapter-relative storage key
  • $visibility string β€” public|private

exists()

exists($key, $visibility)

Does the blob exist?

  • $key string β€” the adapter-relative storage key
  • $visibility string β€” public|private

Returns bool β€” true when the blob exists

size()

size($key, $visibility)

Size of a blob in bytes (0 if missing).

  • $key string β€” the adapter-relative storage key
  • $visibility string β€” public|private

Returns int β€” the blob size in bytes, or 0 if missing

url()

url($key, $visibility, $ttl = null)

A directly-usable URL for a blob (CDN/endpoint for public, a SAS URL for private).

  • $key string β€” the adapter-relative storage key
  • $visibility string β€” public|private
  • $ttl ?int β€” seconds for the private SAS URL (adapter default when null)

Returns string β€” a usable URL, or '' when the app must stream the bytes itself