DIRECTORY_MODE
DIRECTORY_MODE = 0755
Directory mode for created directories.
Stores objects on the local filesystem.
Three real uses: the kernel test lane, which needs a store with no network; a staging tier a site can flush to before a slower upload; and a target for an export a human is going to copy.
Writes are atomic. Every object lands in a temporary file in the same directory and is renamed into place, so a crash mid-write leaves either the previous object or none, never a half one. A reader that saw a truncated object would treat it as a corrupt frame and quarantine a commit that is actually intact.
head(string $key) : \Drupal\strata\Storage\ObjectMeta|null
Metadata for one object without reading it.
| string | $key | Object key relative to the store root. |
The metadata, or NULL when the object is absent. Absence is not an error, because every caller of this method is asking precisely in order to find out.
put(string $key, mixed $body, array $options = []) : \Drupal\strata\Storage\PutResult
Writes an object.
| string | $key | Object key relative to the store root. |
| mixed | $body | The bytes, or an open readable stream. A stream is read once and not rewound, so a caller that needs it again must seek itself. |
| array | $options | Provider options. |
What was written.
delete(array $keys) : int
Deletes objects.
| array | $keys | Object keys relative to the store root. |
How many keys the endpoint accepted. A store that can tell an absent key from a removed one counts only what it removed; S3 reports success for an absent key and cannot distinguish, so it counts everything it was given. Do not read this as "how many existed" - a prune receipt counts from the frame index, which knows.
list(string $prefix = '', ?string $cursor = null, int $limit = 1000, ?string $delimiter = null) : \Drupal\strata\Storage\ObjectPage
Lists one page of objects under a prefix.
| string | $prefix | Key prefix relative to the store root; an empty string lists everything. |
| ?string | $cursor | Continuation token from a previous page, or NULL to start. |
| int | $limit | Most objects to return in this page. |
| ?string | $delimiter | Grouping delimiter, or NULL for a flat listing. |
The page.
missingWrapper() : string|null
Why the root's stream wrapper cannot be used, if it cannot.
A root may be a plain path or a stream URI, and private:// is the one a Drupal site is most
likely to be pointed at. That scheme only exists once file_private_path is set, and every
filesystem call against an unregistered scheme emits a PHP warning and answers FALSE - which
reads as "the directory is missing" and sends an operator looking for the wrong thing.
The reason, or NULL when the root is usable as far as its scheme goes.
resolve(string $key) : string
Turns a key into an absolute path, refusing anything that escapes the root.
A key arrives from a manifest, and a manifest can be tampered with, so a . or .. segment is
rejected by name rather than normalised away: normalising one would silently address a
different object than the manifest named.
A leading or trailing slash is the one thing that IS normalised, because it names the same
object either way and an endpoint that keeps it produces a key with an empty first segment.
/frames/aa therefore resolves inside the root rather than at the filesystem root.
| string | $key | Object key relative to the store root. |
When the key is empty, has an empty inner segment, contains a . or .. segment or a null
byte, or ends in the reserved in-progress suffix.
Absolute path inside the root.
pruneEmptyDirectories(string $path) : void
Removes directories left empty by a delete, up to the root.
A sharded store creates 65,536 directories; without this a bucket that has been fully pruned still carries all of them.
| string | $path | The directory to start from. |
copyStream(resource $source, string $destination, string $key) : int
Copies a stream into a file.
| resource | $source | An open readable stream. |
| string | $destination | Path to write. |
| string | $key | The object key, for error messages. |
When either side fails.
Bytes written.
etag(string $path, int $size) : string
An entity tag for a stored object.
Derived from size and modification time rather than content, so heading an object stays a stat rather than a read. Consumers treat an etag as opaque and compare it only to another etag from the same store.
| string | $path | Absolute path to the object. |
| int | $size | Size in bytes. |
The tag.