PREFIX
PREFIX = 'media'
Key prefix blocks are stored under.
Stores file blocks and the maps that reassemble them.
Blocks are content-addressed and shared across every file and every version that contains them, so the same image uploaded twice under two names costs one copy, and the second version of a video costs the blocks that changed.
Blocks are stored raw: not compressed, not delta coded, not framed. Media is already compressed
Blocks live outside the site namespace. A block is addressed by the digest of its content, so two sites sharing a bucket share their identical media, which is the point of sharing a bucket. The maps that describe which blocks make up which file are per-site, because a path belongs to a site.
$provider : \Drupal\strata\Storage\StorageProviderInterface
$splitter : \Drupal\strata\File\BlockSplitter
$classes : \Drupal\strata\File\StorageClassPolicy
__construct(\Drupal\strata\Storage\StorageProviderInterface $provider, \Drupal\strata\File\BlockSplitter $splitter, \Drupal\strata\File\StorageClassPolicy $classes = new \Drupal\strata\File\StorageClassPolicy()) : mixed
Constructs a store.
| \Drupal\strata\Storage\StorageProviderInterface | $provider | Where blocks and maps are written. |
| \Drupal\strata\File\BlockSplitter | $splitter | Splits a file into blocks. |
| \Drupal\strata\File\StorageClassPolicy | $classes | Decides which storage class a block is written to. |
store(string $path, string|null $storedAs = null) : array{map: \Drupal\strata\File\FileMap, key: string, uploaded: int, skipped: int, bytes: int}
Stores a file, uploading only the blocks that are not already there.
| string | $path | Path to the file on disk. |
| string|null | $storedAs | The path to record in the map, when it differs from where the file sits on disk - a managed file's URI rather than its resolved location. NULL records the path as given. |
When the file cannot be read or a block cannot be written.
The map, the key it was written to, how many blocks were uploaded, how many were already present, and how many bytes went out.
block(string $hash) : string
Reads one block.
| string | $hash | Its content address. |
When the block is absent, or its bytes do not hash to the address it is filed under. A block that does not match its address is corruption, and reassembling a file out of it would produce a file that looks intact and is not.
The block's content.
reassemble(\Drupal\strata\File\FileMap $map, string $destination) : int
Writes a file back out from its map.
| \Drupal\strata\File\FileMap | $map | The version to reassemble. |
| string | $destination | Where to write it. |
When a block is missing or the destination cannot be written. A partly reassembled file is deleted rather than left behind, because a truncated video looks like a file and is not one.
Bytes written.
missing(\Drupal\strata\File\FileMap $map) : list<string>
Which of a map's blocks are missing from the store.
What a verify pass over the file realm reports, and what tells a map that cannot be restored from one that can.
| \Drupal\strata\File\FileMap | $map | The version to check. |
Addresses of the absent blocks, deduplicated.