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).
$keystring— the adapter-relative storage key$sourcePathstring— the source file on disk to copy from$visibilitystring— 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).
$keystring— the adapter-relative storage key$bytesstring— the raw bytes to store$visibilitystring— public|private$mime?string— the content MIME type (may be null)
get()
get($key, $visibility)
Read all bytes.
$keystring— the adapter-relative storage key$visibilitystring— 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).
$keystring— the adapter-relative storage key$visibilitystring— public|private
Returns resource — a readable stream for the object
delete()
delete($key, $visibility)
Remove the object (idempotent — missing is not an error).
$keystring— the adapter-relative storage key$visibilitystring— public|private
exists()
exists($key, $visibility)
Does the object exist?
$keystring— the adapter-relative storage key$visibilitystring— public|private
Returns bool — true when the object exists
size()
size($key, $visibility)
Size in bytes (0 if missing).
$keystring— the adapter-relative storage key$visibilitystring— 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/
$keystring— the adapter-relative storage key$visibilitystring— public|private$ttlint|null— seconds for a signed URL (backend default when null)
Returns string — a usable URL, or '' when the caller must serve the bytes itself