Tiger_Media_Storage_Interface

@api

Tiger_Media_Storage_Interface β€” the pluggable storage backend for media bytes.

The media table holds metadata; the actual bytes live behind one of these adapters (filesystem / S3 / GCS / Azure), selected per-file by the row's disk. visibility (public|private) is passed to every locating call because it can change WHERE/HOW a backend stores or serves an object (a filesystem adapter keeps public files under the docroot and private files outside it; S3 sets the object ACL). Keys are adapter-relative, tenant-namespaced paths built by the upload service β€” <org_id>/<kind-folder>/<rand>.<ext> (e.g. 3f2504e0-…/images/ab12….jpg); the adapter prepends the visibility root (public/ | private/). The immutable <org_id> segment keeps tenants' bytes separated.

Methods

put()

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

Store bytes from a source file path (e.g. an upload tmp file).

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

write()

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

Store raw bytes (e.g. a generated thumbnail held in memory).

  • $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.

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

Returns string β€” the object's bytes

stream()

stream($key, $visibility)

Open a read stream (for large files β€” avoids loading them fully into memory).

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

Returns resource β€” a readable stream for the object

delete()

delete($key, $visibility)

Remove the object (idempotent β€” missing is not an error).

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

exists()

exists($key, $visibility)

Does the object exist?

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

Returns bool β€” true when the object exists

size()

size($key, $visibility)

Size in bytes (0 if missing).

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

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

url()

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

A directly-usable URL, or '' when the caller must serve it itself. Public objects always yield a URL (direct path / CDN); private objects yield a signed URL when the backend supports one (S3 presign), else '' β€” the media layer then serves it through the ACL-checked streamer route (/media/file/).

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

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